2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.api;
10 import static com.google.common.base.Preconditions.checkArgument;
11 import static com.google.common.base.Verify.verify;
12 import static java.util.Objects.requireNonNull;
14 import com.google.common.annotations.Beta;
15 import com.google.common.cache.CacheBuilder;
16 import com.google.common.cache.CacheLoader;
17 import com.google.common.cache.LoadingCache;
18 import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.ImmutableMap;
20 import com.google.common.collect.ImmutableSet;
21 import com.google.common.collect.Iterables;
22 import com.google.common.collect.Sets;
23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
24 import java.io.Serializable;
25 import java.lang.reflect.Array;
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.Collection;
29 import java.util.Deque;
30 import java.util.Iterator;
31 import java.util.List;
33 import java.util.Map.Entry;
34 import java.util.Objects;
35 import java.util.Optional;
37 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
38 import java.util.function.Function;
39 import org.eclipse.jdt.annotation.NonNull;
40 import org.eclipse.jdt.annotation.Nullable;
41 import org.opendaylight.yangtools.concepts.Builder;
42 import org.opendaylight.yangtools.concepts.Immutable;
43 import org.opendaylight.yangtools.concepts.Path;
44 import org.opendaylight.yangtools.util.HashCodeBuilder;
45 import org.opendaylight.yangtools.util.ImmutableOffsetMap;
46 import org.opendaylight.yangtools.util.SharedSingletonMap;
47 import org.opendaylight.yangtools.yang.common.QName;
48 import org.opendaylight.yangtools.yang.common.QNameModule;
49 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
52 * Unique identifier of a particular node instance in the data tree.
55 * Java representation of YANG Built-in type <code>instance-identifier</code>,
56 * which conceptually is XPath expression minimized to uniquely identify element
57 * in data tree which conforms to constraints maintained by YANG Model,
58 * effectively this makes Instance Identifier a path to element in data tree.
61 * Constraints put in YANG specification on instance-identifier allowed it to be
62 * effectively represented in Java and it's evaluation does not require
63 * full-blown XPath processor.
66 * <h3>Path Arguments</h3>
67 * Path to the node represented in instance identifier consists of
68 * {@link PathArgument} which carries necessary information to uniquely identify
69 * node on particular level in the subtree.
72 * <li>{@link NodeIdentifier} - Identifier of node, which has cardinality
73 * <code>0..1</code> in particular subtree in data tree.</li>
74 * <li>{@link NodeIdentifierWithPredicates} - Identifier of node (list item),
75 * which has cardinality <code>0..n</code>.</li>
76 * <li>{@link NodeWithValue} - Identifier of instance <code>leaf</code> node or
77 * <code>leaf-list</code> node.</li>
78 * <li>{@link AugmentationIdentifier} - Identifier of instance of
79 * <code>augmentation</code> node.</li>
82 * @see <a href="http://tools.ietf.org/html/rfc6020#section-9.13">RFC6020</a>
84 // FIXME: 4.0.0: this concept needs to be moved to yang-common, as parser components need the ability to refer
85 // to data nodes -- most notably XPath expressions and {@code default} statement arguments need to be able
86 // to represent these.
87 // FIXME: FixedYangInstanceIdentifier needs YangInstanceIdentifier initialized, but that includes initializing
88 // this field. Figure out a way out of this pickle.
89 @SuppressFBWarnings("IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION")
90 public abstract class YangInstanceIdentifier implements Path<YangInstanceIdentifier>, Immutable, Serializable {
92 * An empty {@link YangInstanceIdentifier}. It corresponds to the path of the conceptual root of the YANG namespace.
94 public static final YangInstanceIdentifier EMPTY = FixedYangInstanceIdentifier.EMPTY_INSTANCE;
96 private static final AtomicReferenceFieldUpdater<YangInstanceIdentifier, String> TOSTRINGCACHE_UPDATER =
97 AtomicReferenceFieldUpdater.newUpdater(YangInstanceIdentifier.class, String.class, "toStringCache");
98 private static final long serialVersionUID = 4L;
100 private final int hash;
101 private transient volatile String toStringCache = null;
103 // Package-private to prevent outside subclassing
104 YangInstanceIdentifier(final int hash) {
108 abstract @NonNull YangInstanceIdentifier createRelativeIdentifier(int skipFromRoot);
110 abstract @Nullable Collection<PathArgument> tryPathArguments();
112 abstract @Nullable Collection<PathArgument> tryReversePathArguments();
115 * Check if this instance identifier has empty path arguments, e.g. it is
116 * empty and corresponds to {@link #EMPTY}.
118 * @return True if this instance identifier is empty, false otherwise.
120 public abstract boolean isEmpty();
123 * Return an optimized version of this identifier, useful when the identifier
124 * will be used very frequently.
126 * @return A optimized equivalent instance.
129 public abstract YangInstanceIdentifier toOptimized();
132 * Return the conceptual parent {@link YangInstanceIdentifier}, which has
133 * one item less in {@link #getPathArguments()}.
135 * @return Parent {@link YangInstanceIdentifier}, or null if this object is {@link #EMPTY}.
137 public abstract @Nullable YangInstanceIdentifier getParent();
140 * Return the ancestor {@link YangInstanceIdentifier} with a particular depth, e.g. number of path arguments.
142 * @param depth Ancestor depth
143 * @return Ancestor {@link YangInstanceIdentifier}
144 * @throws IllegalArgumentException if the specified depth is negative or is greater than the depth of this object.
146 public abstract @NonNull YangInstanceIdentifier getAncestor(int depth);
149 * Returns an ordered iteration of path arguments.
151 * @return Immutable iteration of path arguments.
153 public abstract List<PathArgument> getPathArguments();
156 * Returns an iterable of path arguments in reverse order. This is useful
157 * when walking up a tree organized this way.
159 * @return Immutable iterable of path arguments in reverse order.
161 public abstract List<PathArgument> getReversePathArguments();
164 * Returns the last PathArgument. This is equivalent of iterating
165 * to the last element of the iterable returned by {@link #getPathArguments()}.
167 * @return The last past argument, or null if there are no PathArguments.
169 public abstract PathArgument getLastPathArgument();
171 public static YangInstanceIdentifier create(final Iterable<? extends PathArgument> path) {
172 if (Iterables.isEmpty(path)) {
176 final HashCodeBuilder<PathArgument> hash = new HashCodeBuilder<>();
177 for (PathArgument a : path) {
181 return FixedYangInstanceIdentifier.create(path, hash.build());
184 public static YangInstanceIdentifier create(final PathArgument... path) {
185 // We are forcing a copy, since we cannot trust the user
186 return create(Arrays.asList(path));
190 * Create a {@link YangInstanceIdentifier} by taking a snapshot of provided path and iterating it backwards.
192 * @param pathTowardsRoot Path towards root
193 * @return A {@link YangInstanceIdentifier} instance
194 * @throws NullPointerException if {@code pathTowardsRoot} or any of its members is null
196 public static YangInstanceIdentifier createReverse(final Deque<PathArgument> pathTowardsRoot) {
197 final ImmutableList.Builder<PathArgument> builder = ImmutableList.builderWithExpectedSize(
198 pathTowardsRoot.size());
199 pathTowardsRoot.descendingIterator().forEachRemaining(builder::add);
200 return YangInstanceIdentifier.create(builder.build());
204 * Create a {@link YangInstanceIdentifier} by walking specified stack backwards and extracting path components
207 * @param stackTowardsRoot Stack towards root,
208 * @return A {@link YangInstanceIdentifier} instance
209 * @throws NullPointerException if {@code pathTowardsRoot} is null
211 public static <T> YangInstanceIdentifier createReverse(final Deque<? extends T> stackTowardsRoot,
212 final Function<T, PathArgument> function) {
213 final ImmutableList.Builder<PathArgument> builder = ImmutableList.builderWithExpectedSize(
214 stackTowardsRoot.size());
215 final Iterator<? extends T> it = stackTowardsRoot.descendingIterator();
216 while (it.hasNext()) {
217 builder.add(function.apply(it.next()));
219 return YangInstanceIdentifier.create(builder.build());
222 boolean pathArgumentsEqual(final YangInstanceIdentifier other) {
223 return Iterables.elementsEqual(getPathArguments(), other.getPathArguments());
227 public boolean equals(final Object obj) {
231 if (!(obj instanceof YangInstanceIdentifier)) {
234 YangInstanceIdentifier other = (YangInstanceIdentifier) obj;
235 if (this.hashCode() != obj.hashCode()) {
239 return pathArgumentsEqual(other);
243 * Constructs a new Instance Identifier with new {@link NodeIdentifier} added to the end of path arguments.
245 * @param name QName of {@link NodeIdentifier}
246 * @return Instance Identifier with additional path argument added to the end.
248 public final YangInstanceIdentifier node(final QName name) {
249 return node(new NodeIdentifier(name));
253 * Constructs a new Instance Identifier with new {@link PathArgument} added to the end of path arguments.
255 * @param arg Path argument which should be added to the end
256 * @return Instance Identifier with additional path argument added to the end.
258 public final YangInstanceIdentifier node(final PathArgument arg) {
259 return new StackedYangInstanceIdentifier(this, arg, HashCodeBuilder.nextHashCode(hash, arg));
263 * Get the relative path from an ancestor. This method attempts to perform
264 * the reverse of concatenating a base (ancestor) and a path.
267 * Ancestor against which the relative path should be calculated
268 * @return This object's relative path from parent, or Optional.absent() if
269 * the specified parent is not in fact an ancestor of this object.
271 public Optional<YangInstanceIdentifier> relativeTo(final YangInstanceIdentifier ancestor) {
272 if (this == ancestor) {
273 return Optional.of(EMPTY);
275 if (ancestor.isEmpty()) {
276 return Optional.of(this);
279 final Iterator<PathArgument> lit = getPathArguments().iterator();
280 final Iterator<PathArgument> oit = ancestor.getPathArguments().iterator();
283 while (oit.hasNext()) {
284 // Ancestor is not really an ancestor
285 if (!lit.hasNext() || !lit.next().equals(oit.next())) {
286 return Optional.empty();
293 return Optional.of(this);
295 if (!lit.hasNext()) {
296 return Optional.of(EMPTY);
299 return Optional.of(createRelativeIdentifier(common));
303 public final boolean contains(final YangInstanceIdentifier other) {
308 checkArgument(other != null, "other should not be null");
309 final Iterator<PathArgument> lit = getPathArguments().iterator();
310 final Iterator<PathArgument> oit = other.getPathArguments().iterator();
312 while (lit.hasNext()) {
313 if (!oit.hasNext()) {
317 if (!lit.next().equals(oit.next())) {
326 public final String toString() {
328 * The toStringCache is safe, since the object contract requires
329 * immutability of the object and all objects referenced from this
331 * Used lists, maps are immutable. Path Arguments (elements) are also
332 * immutable, since the PathArgument contract requires immutability.
333 * The cache is thread-safe - if multiple computations occurs at the
334 * same time, cache will be overwritten with same result.
336 String ret = toStringCache;
338 final StringBuilder builder = new StringBuilder("/");
339 PathArgument prev = null;
340 for (PathArgument argument : getPathArguments()) {
344 builder.append(argument.toRelativeString(prev));
348 ret = builder.toString();
349 TOSTRINGCACHE_UPDATER.lazySet(this, ret);
355 public final int hashCode() {
357 * The caching is safe, since the object contract requires
358 * immutability of the object and all objects referenced from this
360 * Used lists, maps are immutable. Path Arguments (elements) are also
361 * immutable, since the PathArgument contract requires immutability.
366 private static int hashCode(final Object value) {
371 if (byte[].class.equals(value.getClass())) {
372 return Arrays.hashCode((byte[]) value);
375 if (value.getClass().isArray()) {
377 int length = Array.getLength(value);
378 for (int i = 0; i < length; i++) {
379 hash += Objects.hashCode(Array.get(value, i));
385 return Objects.hashCode(value);
388 final Object writeReplace() {
389 return new YIDv1(this);
392 // Static factories & helpers
395 * Returns a new InstanceIdentifier with only one path argument of type {@link NodeIdentifier} with supplied
398 * @param name QName of first node identifier
399 * @return Instance Identifier with only one path argument of type {@link NodeIdentifier}
401 public static YangInstanceIdentifier of(final QName name) {
402 return create(new NodeIdentifier(name));
406 * Returns new builder for InstanceIdentifier with empty path arguments.
408 * @return new builder for InstanceIdentifier with empty path arguments.
410 public static InstanceIdentifierBuilder builder() {
411 return new YangInstanceIdentifierBuilder();
415 * Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.
417 * @param origin InstanceIdentifier from which path arguments are copied.
418 * @return new builder for InstanceIdentifier with path arguments copied from original instance identifier.
420 public static InstanceIdentifierBuilder builder(final YangInstanceIdentifier origin) {
421 return new YangInstanceIdentifierBuilder(origin.getPathArguments(), origin.hashCode());
425 * Path argument / component of InstanceIdentifier.
426 * Path argument uniquely identifies node in data tree on particular
430 * This interface itself is used as common parent for actual
431 * path arguments types and should not be implemented by user code.
434 * Path arguments SHOULD contain only minimum of information
435 * required to uniquely identify node on particular subtree level.
438 * For actual path arguments types see:
440 * <li>{@link NodeIdentifier} - Identifier of container or leaf
441 * <li>{@link NodeIdentifierWithPredicates} - Identifier of list entries, which have key defined
442 * <li>{@link AugmentationIdentifier} - Identifier of augmentation
443 * <li>{@link NodeWithValue} - Identifier of leaf-list entry
446 public interface PathArgument extends Comparable<PathArgument>, Immutable, Serializable {
448 * If applicable returns unique QName of data node as defined in YANG
452 * This method may return null, if the corresponding schema node, does
453 * not have QName associated, such as in cases of augmentations.
460 * Return the string representation of this object for use in context
461 * provided by a previous object. This method can be implemented in
462 * terms of {@link #toString()}, but implementations are encourage to
463 * reuse any context already emitted by the previous object.
465 * @param previous Previous path argument
466 * @return String representation
468 String toRelativeString(PathArgument previous);
471 private abstract static class AbstractPathArgument implements PathArgument {
472 private static final long serialVersionUID = -4546547994250849340L;
473 private final QName nodeType;
474 private transient int hashValue;
475 private transient volatile boolean hashGuard = false;
477 protected AbstractPathArgument(final QName nodeType) {
478 this.nodeType = requireNonNull(nodeType);
482 public final QName getNodeType() {
487 @SuppressWarnings("checkstyle:parameterName")
488 public int compareTo(final PathArgument o) {
489 return nodeType.compareTo(o.getNodeType());
492 protected int hashCodeImpl() {
493 return 31 + getNodeType().hashCode();
497 public final int hashCode() {
499 hashValue = hashCodeImpl();
507 public boolean equals(final Object obj) {
511 if (obj == null || this.getClass() != obj.getClass()) {
515 return getNodeType().equals(((AbstractPathArgument)obj).getNodeType());
519 public String toString() {
520 return getNodeType().toString();
524 public String toRelativeString(final PathArgument previous) {
525 if (previous instanceof AbstractPathArgument) {
526 final QNameModule mod = previous.getNodeType().getModule();
527 if (getNodeType().getModule().equals(mod)) {
528 return getNodeType().getLocalName();
532 return getNodeType().toString();
535 abstract Object writeReplace();
539 * Simple path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.ContainerNode} or
540 * {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} leaf in particular subtree.
542 public static final class NodeIdentifier extends AbstractPathArgument {
543 private static final long serialVersionUID = -2255888212390871347L;
544 private static final LoadingCache<QName, NodeIdentifier> CACHE = CacheBuilder.newBuilder().weakValues()
545 .build(new CacheLoader<QName, NodeIdentifier>() {
547 public NodeIdentifier load(final QName key) {
548 return new NodeIdentifier(key);
552 public NodeIdentifier(final QName node) {
557 * Return a NodeIdentifier for a particular QName. Unlike the constructor, this factory method uses a global
558 * instance cache, resulting in object reuse for equal inputs.
560 * @param node Node's QName
561 * @return A {@link NodeIdentifier}
563 public static NodeIdentifier create(final QName node) {
564 return CACHE.getUnchecked(node);
568 Object writeReplace() {
569 return new NIv1(this);
574 * Composite path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode} leaf
577 public static final class NodeIdentifierWithPredicates extends AbstractPathArgument {
578 private static final long serialVersionUID = -4787195606494761540L;
580 private final Map<QName, Object> keyValues;
583 NodeIdentifierWithPredicates(final Map<QName, Object> keyValues, final QName node) {
585 this.keyValues = requireNonNull(keyValues);
588 public NodeIdentifierWithPredicates(final QName node) {
590 this.keyValues = ImmutableMap.of();
593 public NodeIdentifierWithPredicates(final QName node, final Map<QName, Object> keyValues) {
595 // Retains ImmutableMap for empty maps. For larger sizes uses a shared key set.
596 this.keyValues = ImmutableOffsetMap.unorderedCopyOf(keyValues);
599 public NodeIdentifierWithPredicates(final QName node, final ImmutableOffsetMap<QName, Object> keyValues) {
600 this(keyValues, node);
603 public NodeIdentifierWithPredicates(final QName node, final SharedSingletonMap<QName, Object> keyValues) {
604 this(keyValues, node);
607 public NodeIdentifierWithPredicates(final QName node, final QName key, final Object value) {
608 this(node, SharedSingletonMap.unorderedOf(key, value));
611 public Map<QName, Object> getKeyValues() {
616 protected int hashCodeImpl() {
617 final int prime = 31;
618 int result = super.hashCodeImpl();
619 result = prime * result;
621 for (Entry<QName, Object> entry : keyValues.entrySet()) {
622 result += Objects.hashCode(entry.getKey()) + YangInstanceIdentifier.hashCode(entry.getValue());
628 @SuppressWarnings("checkstyle:equalsHashCode")
629 public boolean equals(final Object obj) {
630 if (!super.equals(obj)) {
634 final Map<QName, Object> otherKeyValues = ((NodeIdentifierWithPredicates) obj).keyValues;
636 // TODO: benchmark to see if just calling equals() on the two maps is not faster
637 if (keyValues == otherKeyValues) {
640 if (keyValues.size() != otherKeyValues.size()) {
644 for (Entry<QName, Object> entry : keyValues.entrySet()) {
645 if (!otherKeyValues.containsKey(entry.getKey())
646 || !Objects.deepEquals(entry.getValue(), otherKeyValues.get(entry.getKey()))) {
656 public String toString() {
657 return super.toString() + '[' + keyValues + ']';
661 public String toRelativeString(final PathArgument previous) {
662 return super.toRelativeString(previous) + '[' + keyValues + ']';
666 Object writeReplace() {
667 return new NIPv1(this);
672 * Simple path argument identifying a {@link LeafSetEntryNode} leaf
675 public static final class NodeWithValue<T> extends AbstractPathArgument {
676 private static final long serialVersionUID = -3637456085341738431L;
678 private final T value;
680 public NodeWithValue(final QName node, final T value) {
685 public T getValue() {
690 protected int hashCodeImpl() {
691 final int prime = 31;
692 int result = super.hashCodeImpl();
693 result = prime * result + YangInstanceIdentifier.hashCode(value);
698 @SuppressWarnings("checkstyle:equalsHashCode")
699 public boolean equals(final Object obj) {
700 if (!super.equals(obj)) {
703 final NodeWithValue<?> other = (NodeWithValue<?>) obj;
704 return Objects.deepEquals(value, other.value);
708 public String toString() {
709 return super.toString() + '[' + value + ']';
713 public String toRelativeString(final PathArgument previous) {
714 return super.toRelativeString(previous) + '[' + value + ']';
718 Object writeReplace() {
719 return new NIVv1(this);
724 * Composite path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode}
725 * node in particular subtree.
728 * Augmentation is uniquely identified by set of all possible child nodes.
730 * to identify instance of augmentation,
731 * since RFC6020 states that <code>augment</code> that augment
732 * statement must not add multiple nodes from same namespace
733 * / module to the target node.
735 * @see <a href="http://tools.ietf.org/html/rfc6020#section-7.15">RFC6020</a>
737 public static final class AugmentationIdentifier implements PathArgument {
738 private static final long serialVersionUID = -8122335594681936939L;
739 private final ImmutableSet<QName> childNames;
742 public QName getNodeType() {
743 // This should rather throw exception than return always null
744 throw new UnsupportedOperationException("Augmentation node has no QName");
748 * Construct new augmentation identifier using supplied set of possible
752 * Set of possible child nodes.
754 public AugmentationIdentifier(final Set<QName> childNames) {
755 this.childNames = ImmutableSet.copyOf(childNames);
759 * Returns set of all possible child nodes.
761 * @return set of all possible child nodes.
763 public Set<QName> getPossibleChildNames() {
768 public String toString() {
769 return "AugmentationIdentifier{" + "childNames=" + childNames + '}';
773 public String toRelativeString(final PathArgument previous) {
778 public boolean equals(final Object obj) {
782 if (!(obj instanceof AugmentationIdentifier)) {
786 AugmentationIdentifier that = (AugmentationIdentifier) obj;
787 return childNames.equals(that.childNames);
791 public int hashCode() {
792 return childNames.hashCode();
796 @SuppressWarnings("checkstyle:parameterName")
797 public int compareTo(final PathArgument o) {
798 if (!(o instanceof AugmentationIdentifier)) {
801 AugmentationIdentifier other = (AugmentationIdentifier) o;
802 Set<QName> otherChildNames = other.getPossibleChildNames();
803 int thisSize = childNames.size();
804 int otherSize = otherChildNames.size();
805 if (thisSize == otherSize) {
806 // Quick Set-based comparison
807 if (childNames.equals(otherChildNames)) {
811 // We already know the sets are not equal, but have equal size, hence the sets differ in their elements,
812 // but potentially share a common set of elements. The most consistent way of comparing them is using
813 // total ordering defined by QName's compareTo. Hence convert both sets to lists ordered
814 // by QName.compareTo() and decide on the first differing element.
815 final List<QName> diff = new ArrayList<>(Sets.symmetricDifference(childNames, otherChildNames));
816 verify(!diff.isEmpty(), "Augmentation identifiers %s and %s report no difference", this, o);
817 diff.sort(QName::compareTo);
818 return childNames.contains(diff.get(0)) ? -1 : 1;
819 } else if (thisSize < otherSize) {
826 private Object writeReplace() {
827 return new AIv1(this);
832 * Fluent Builder of Instance Identifier instances.
834 public interface InstanceIdentifierBuilder extends Builder<YangInstanceIdentifier> {
836 * Adds a {@link PathArgument} to path arguments of resulting instance identifier.
838 * @param arg A {@link PathArgument} to be added
839 * @return this builder
841 InstanceIdentifierBuilder node(PathArgument arg);
844 * Adds {@link NodeIdentifier} with supplied QName to path arguments of resulting instance identifier.
846 * @param nodeType QName of {@link NodeIdentifier} which will be added
847 * @return this builder
849 InstanceIdentifierBuilder node(QName nodeType);
852 * Adds {@link NodeIdentifierWithPredicates} with supplied QName and key values to path arguments of resulting
853 * instance identifier.
855 * @param nodeType QName of {@link NodeIdentifierWithPredicates} which will be added
856 * @param keyValues Map of key components and their respective values for {@link NodeIdentifierWithPredicates}
857 * @return this builder
859 InstanceIdentifierBuilder nodeWithKey(QName nodeType, Map<QName, Object> keyValues);
862 * Adds {@link NodeIdentifierWithPredicates} with supplied QName and key, value.
864 * @param nodeType QName of {@link NodeIdentifierWithPredicates} which will be added
865 * @param key QName of key which will be added
866 * @param value value of key which will be added
867 * @return this builder
869 InstanceIdentifierBuilder nodeWithKey(QName nodeType, QName key, Object value);
872 * Adds a collection of {@link PathArgument}s to path arguments of resulting instance identifier.
874 * @param args {@link PathArgument}s to be added
875 * @return this builder
876 * @throws NullPointerException if any of the arguments is null
879 InstanceIdentifierBuilder append(Collection<? extends PathArgument> args);
882 * Adds a collection of {@link PathArgument}s to path arguments of resulting instance identifier.
884 * @param args {@link PathArgument}s to be added
885 * @return this builder
886 * @throws NullPointerException if any of the arguments is null
889 default InstanceIdentifierBuilder append(final PathArgument... args) {
890 return append(Arrays.asList(args));
894 * Builds an {@link YangInstanceIdentifier} with path arguments from this builder.
896 * @return {@link YangInstanceIdentifier}
899 YangInstanceIdentifier build();