/** * Create an instance identifier for a very specific object type. * * For example * <pre> * new InstanceIdentifier(Nodes.class) * </pre> * would create an InstanceIdentifier for an object of type Nodes * * @param type The type of the object which this instance identifier represents * @return InstanceIdentifier instance */ @SuppressWarnings("unchecked") public static <T extends DataObject> InstanceIdentifier<T> create(final Class<T> type) { return (InstanceIdentifier<T>) create(Collections.<PathArgument> singletonList(new Item<>(type))); }
/** * Returns container child modification if {@code child} was modified by this modification. This method should be * used if the child is defined in a grouping brought into a case inside this object. * * <p> * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}. * * @param caseType Case type class * @param child Type of child - must be only container * @return Modification of {@code child} if {@code child} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code child} class is not valid child according * to generated model. */ default @Nullable <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> DataObjectModification<C> getModifiedChildContainer(@Nonnull final Class<H> caseType, @Nonnull final Class<C> child) { return (DataObjectModification<C>) getModifiedChild(Item.of(caseType, child)); }
@Override public String toString() { return getType().getName(); } }
/** * Create an instance identifier for a very specific object type. * * <p> * For example * <pre> * new InstanceIdentifier(Nodes.class) * </pre> * would create an InstanceIdentifier for an object of type Nodes * * @param type The type of the object which this instance identifier represents * @return InstanceIdentifier instance */ @SuppressWarnings("unchecked") public static <T extends DataObject> InstanceIdentifier<T> create(final Class<T> type) { return (InstanceIdentifier<T>) create(ImmutableList.of(Item.of(type))); }
/** * Returns child list item modification if {@code child} was modified by this modification. This method should be * used if the child is defined in a grouping brought into a case inside this object. * * @param caseType Case type class * @param childType Type of list item - must be list item with key * @return Modification of {@code child} if {@code child} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according * to generated model. */ default <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> Collection<DataObjectModification<C>> getModifiedChildren(@Nonnull final Class<H> caseType, @Nonnull final Class<C> childType) { final Item<C> item = Item.of(caseType, childType); return (Collection<DataObjectModification<C>>) Collections2.filter(getModifiedChildren(), mod -> item.equals(mod.getIdentifier())); }
/** * Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier as specified by container in * a {@code grouping} used in the {@code case} statement. * * @param caze Choice case class * @param container Base container * @param <C> Case type * @param <T> Type of the container * @return A new {@link InstanceIdentifierBuilder} * @throws NullPointerException if any argument is null */ public static <C extends ChoiceIn<? extends DataRoot> & DataObject, T extends ChildOf<? super C>> InstanceIdentifierBuilder<T> builder(final Class<C> caze, final Class<T> container) { return new InstanceIdentifierBuilderImpl<T>().addWildNode(Item.of(caze, container)); }
/** * Create an InstanceIdentifier for a child container. This method is a more efficient equivalent to * {@code builder().child(caze, container).build()}. * * @param caze Choice case class * @param container Container to append * @param <C> Case type * @param <N> Container type * @return An InstanceIdentifier. * @throws NullPointerException if any argument is null */ public final <C extends ChoiceIn<? super T> & DataObject, N extends ChildOf<? super C>> InstanceIdentifier<N> child( final Class<C> caze, final Class<N> container) { return childIdentifier(Item.of(caze, container)); }
protected Class<?> getBindingClass() { return bindingArg.getType(); }
@SuppressWarnings("unchecked") Item<?> createBindingArg(final Class<?> childClass, final DataSchemaNode childSchema) { return Item.of((Class<? extends DataObject>) childClass); }
@Override @SuppressWarnings("unchecked") public <C extends Augmentation<T> & DataObject> DataObjectModification<C> getModifiedAugmentation( final Class<C> augmentation) { return (DataObjectModification<C>) getModifiedChild(Item.of(augmentation)); }
/** * Transform a keyed instance identifier into a wildcarded one, keeping keys except the last item. */ @SuppressWarnings("unchecked") public static <D extends DataObject> InstanceIdentifier<D> makeIidLastWildcarded(final InstanceIdentifier<D> id) { final InstanceIdentifier.Item<D> wildcardedItem = new InstanceIdentifier.Item<>(id.getTargetType()); final Iterable<InstanceIdentifier.PathArgument> pathArguments = id.getPathArguments(); return (InstanceIdentifier<D>) InstanceIdentifier.create( Iterables.concat( Iterables.limit(pathArguments, Iterables.size(pathArguments) - 1), Collections.singleton(wildcardedItem))); }
@SuppressWarnings("unchecked") public static <D extends DataObject> InstanceIdentifier<D> appendTypeToId( final InstanceIdentifier<? extends DataObject> parentId, final InstanceIdentifier<D> type) { final InstanceIdentifier.PathArgument t = new InstanceIdentifier.Item<>(type.getTargetType()); return (InstanceIdentifier<D>) InstanceIdentifier.create(Iterables.concat( parentId.getPathArguments(), Collections.singleton(t))); }
private <N extends DataObject> InstanceIdentifierBuilderImpl<N> addNode(final Class<N> container) { return addWildNode(Item.of(container)); } }
/** * Create an InstanceIdentifier for a child augmentation. This method is a more efficient equivalent to * {@code builder().augmentation(container).build()}. * * @param container Container to append * @param <N> Container type * @return An InstanceIdentifier. * @throws NullPointerException if {@code container} is null */ public final <N extends DataObject & Augmentation<? super T>> InstanceIdentifier<N> augmentation( final Class<N> container) { return childIdentifier(Item.of(container)); }
@SuppressWarnings("unchecked") <N extends DataObject> InstanceIdentifierBuilderImpl<N> addNode(final Class<N> container) { arg = new Item<N>(container); hashBuilder.addArgument(arg); pathBuilder.add(arg); if (Identifiable.class.isAssignableFrom(container)) { wildcard = true; } return (InstanceIdentifierBuilderImpl<N>) this; }
@SuppressWarnings("unchecked") public final <N extends ChildOf<? super T>> InstanceIdentifier<N> child(final Class<N> container) { final PathArgument arg = new Item<>(container); return (InstanceIdentifier<N>) childIdentifier(arg); }
/** * Create a builder rooted at this key. * * @return A builder instance */ public InstanceIdentifierBuilder<T> builder() { return new InstanceIdentifierBuilderImpl<T>(new Item<T>(targetType), pathArguments, hash, isWildcarded()); }
@Override @SuppressWarnings("unchecked") public <C extends ChildOf<? super T>> DataObjectModification<C> getModifiedChildContainer(final Class<C> arg) { return (DataObjectModification<C>) getModifiedChild(new InstanceIdentifier.Item<>(arg)); }
/** * Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier as specified by container. * * @param container Base container * @param <T> Type of the container * @return A new {@link InstanceIdentifierBuilder} * @throws NullPointerException if {@code container} is null */ public static <T extends ChildOf<? extends DataRoot>> InstanceIdentifierBuilder<T> builder( final Class<T> container) { return new InstanceIdentifierBuilderImpl<T>().addWildNode(Item.of(container)); }
@Override @SuppressWarnings("unchecked") public <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> DataObjectModification<C> getModifiedChildContainer(final Class<H> caseType, final Class<C> child) { return (DataObjectModification<C>) getModifiedChild(Item.of(caseType, child)); }