*/
package org.opendaylight.mdsal.binding.generator.impl;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.Identifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
public final class CodecTypeUtils {
-
private CodecTypeUtils() {
throw new UnsupportedOperationException("Utility class should not be instantiated");
}
@SuppressWarnings({"unchecked","rawtypes"})
- public static IdentifiableItem<?, ?> newIdentifiableItem(Class<?> type, Object key) {
- Class<? extends Identifiable<?>> identifiableType = (Class<? extends Identifiable<?>>) type;
- Identifier<? extends Identifiable<?>> identifier = (Identifier<? extends Identifiable<?>>) key;
- return new IdentifiableItem(identifiableType,identifier);
+ public static IdentifiableItem<?, ?> newIdentifiableItem(final Class<?> type, final Object key) {
+ return IdentifiableItem.of((Class)type, (Identifier)key);
}
}
return null;
}
- /**
- * Return the key associated with the first component of specified type in
- * an identifier.
- *
- * @param listItem component type
- * @param listKey component key type
- * @return key associated with the component, or null if the component type
- * is not present.
- *
- * @deprecated Use {@link #firstKeyOf(Class)} instead.
- */
- @Deprecated
- public final <N extends Identifiable<K> & DataObject, K extends Identifier<N>> K firstKeyOf(final Class<N> listItem,
- final Class<K> listKey) {
- return firstKeyOf(listItem);
- }
-
/**
* Return the key associated with the first component of specified type in
* an identifier.
return childIdentifier(Item.of(container));
}
- @Deprecated
- private List<PathArgument> legacyCache;
-
- /**
- * Return the path as a list.
- *
- * @deprecated Use {@link #getPathArguments()} instead.
- */
- @Deprecated
- public final List<PathArgument> getPath() {
- if (legacyCache == null) {
- legacyCache = ImmutableList.<PathArgument>copyOf(pathArguments);
- }
-
- return legacyCache;
- }
-
/**
* Create a builder rooted at this key.
*
public static class Item<T extends DataObject> extends AbstractPathArgument<T> {
private static final long serialVersionUID = 1L;
- /**
- * Construct an Item.
- *
- * @param type Backing class
- * @deprecated Use {@link #of(Class)} instead.
- */
- @Deprecated
- public Item(final Class<T> type) {
+ Item(final Class<T> type) {
super(type);
}
private static final long serialVersionUID = 1L;
private final T key;
- /**
- * Construct an Item.
- *
- * @param type Backing class
- * @param key key
- * @deprecated Use {@link #of(Class, Identifier)} instead.
- */
- @Deprecated
- public IdentifiableItem(final Class<I> type, final T key) {
+ IdentifiableItem(final Class<I> type, final T key) {
super(type);
this.key = requireNonNull(key, "Key may not be null.");
}
final InstanceIdentifier<Node> instanceIdentifier =
InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build();
final InstanceIdentifier<DataObject> instanceIdentifier1 = InstanceIdentifier.create(DataObject.class);
- assertNotNull(instanceIdentifier.firstKeyOf(Node.class, null));
+ assertNotNull(instanceIdentifier.firstKeyOf(Node.class));
assertNull(instanceIdentifier1.firstKeyOf(Node.class));
}
assertFalse(builder3.equals(builder4));
assertFalse(builder4.equals(builder3));
- InstanceIdentifierBuilder<Nodes> iib1 = new InstanceIdentifierBuilderImpl(null, null, 31, true);
- InstanceIdentifierBuilder<Nodes> iib2 = new InstanceIdentifierBuilderImpl(null, null, 31, false);
- InstanceIdentifierBuilder<Nodes> iib3 = new InstanceIdentifierBuilderImpl(null, null, 31, true);
+ InstanceIdentifierBuilder<Nodes> iib1 = new InstanceIdentifierBuilderImpl<>(null, null, 31, true);
+ InstanceIdentifierBuilder<Nodes> iib2 = new InstanceIdentifierBuilderImpl<>(null, null, 31, false);
+ InstanceIdentifierBuilder<Nodes> iib3 = new InstanceIdentifierBuilderImpl<>(null, null, 31, true);
assertFalse(iib1.equals(iib2));
assertFalse(iib2.equals(iib1));
assertTrue(iib1.equals(iib3));