Cleanup checkstyle in yang-{data,model}-api
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / YangInstanceIdentifier.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.api;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Optional;
12 import com.google.common.base.Preconditions;
13 import com.google.common.cache.CacheBuilder;
14 import com.google.common.cache.CacheLoader;
15 import com.google.common.cache.LoadingCache;
16 import com.google.common.collect.ImmutableSet;
17 import com.google.common.collect.Iterables;
18 import java.io.Serializable;
19 import java.lang.reflect.Array;
20 import java.util.Arrays;
21 import java.util.Collection;
22 import java.util.Iterator;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Map.Entry;
26 import java.util.Objects;
27 import java.util.Set;
28 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
29 import javax.annotation.Nonnull;
30 import javax.annotation.Nullable;
31 import org.opendaylight.yangtools.concepts.Builder;
32 import org.opendaylight.yangtools.concepts.Immutable;
33 import org.opendaylight.yangtools.concepts.Path;
34 import org.opendaylight.yangtools.util.HashCodeBuilder;
35 import org.opendaylight.yangtools.util.ImmutableOffsetMap;
36 import org.opendaylight.yangtools.util.SharedSingletonMap;
37 import org.opendaylight.yangtools.yang.common.QName;
38 import org.opendaylight.yangtools.yang.common.QNameModule;
39 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
40
41 /**
42  * Unique identifier of a particular node instance in the data tree.
43  *
44  * <p>
45  * Java representation of YANG Built-in type <code>instance-identifier</code>,
46  * which conceptually is XPath expression minimized to uniquely identify element
47  * in data tree which conforms to constraints maintained by YANG Model,
48  * effectively this makes Instance Identifier a path to element in data tree.
49  *
50  * <p>
51  * Constraints put in YANG specification on instance-identifier allowed it to be
52  * effectively represented in Java and it's evaluation does not require
53  * full-blown XPath processor.
54  *
55  * <p>
56  * <h3>Path Arguments</h3>
57  * Path to the node represented in instance identifier consists of
58  * {@link PathArgument} which carries necessary information to uniquely identify
59  * node on particular level in the subtree.
60  *
61  * <ul>
62  * <li>{@link NodeIdentifier} - Identifier of node, which has cardinality
63  * <code>0..1</code> in particular subtree in data tree.</li>
64  * <li>{@link NodeIdentifierWithPredicates} - Identifier of node (list item),
65  * which has cardinality <code>0..n</code>.</li>
66  * <li>{@link NodeWithValue} - Identifier of instance <code>leaf</code> node or
67  * <code>leaf-list</code> node.</li>
68  * <li>{@link AugmentationIdentifier} - Identifier of instance of
69  * <code>augmentation</code> node.</li>
70  * </ul>
71  *
72  * @see <a href="http://tools.ietf.org/html/rfc6020#section-9.13">RFC6020</a>
73  */
74 public abstract class YangInstanceIdentifier implements Path<YangInstanceIdentifier>, Immutable, Serializable {
75     /**
76      * An empty {@link YangInstanceIdentifier}. It corresponds to the path of the conceptual
77      * root of the YANG namespace.
78      */
79     public static final YangInstanceIdentifier EMPTY = FixedYangInstanceIdentifier.EMPTY_INSTANCE;
80
81     private static final AtomicReferenceFieldUpdater<YangInstanceIdentifier, String> TOSTRINGCACHE_UPDATER =
82             AtomicReferenceFieldUpdater.newUpdater(YangInstanceIdentifier.class, String.class, "toStringCache");
83     private static final long serialVersionUID = 4L;
84
85     private final int hash;
86     private transient volatile String toStringCache = null;
87
88     // Package-private to prevent outside subclassing
89     YangInstanceIdentifier(final int hash) {
90         this.hash = hash;
91     }
92
93     @Nonnull abstract YangInstanceIdentifier createRelativeIdentifier(int skipFromRoot);
94
95     @Nonnull abstract Collection<PathArgument> tryPathArguments();
96
97     @Nonnull abstract Collection<PathArgument> tryReversePathArguments();
98
99     /**
100      * Check if this instance identifier has empty path arguments, e.g. it is
101      * empty and corresponds to {@link #EMPTY}.
102      *
103      * @return True if this instance identifier is empty, false otherwise.
104      */
105     public abstract boolean isEmpty();
106
107     /**
108      * Return an optimized version of this identifier, useful when the identifier
109      * will be used very frequently.
110      *
111      * @return A optimized equivalent instance.
112      */
113     @Beta
114     public abstract YangInstanceIdentifier toOptimized();
115
116     /**
117      * Return the conceptual parent {@link YangInstanceIdentifier}, which has
118      * one item less in {@link #getPathArguments()}.
119      *
120      * @return Parent {@link YangInstanceIdentifier}, or null if this object is {@link #EMPTY}.
121      */
122     @Nullable public abstract YangInstanceIdentifier getParent();
123
124     /**
125      * Return the ancestor {@link YangInstanceIdentifier} with a particular depth, e.g. number of path arguments.
126      *
127      * @param depth Ancestor depth
128      * @return Ancestor {@link YangInstanceIdentifier}
129      * @throws IllegalArgumentException if the specified depth is negative or is greater than the depth of this object.
130      */
131     @Nonnull public abstract YangInstanceIdentifier getAncestor(int depth);
132
133     /**
134      * Returns an ordered iteration of path arguments.
135      *
136      * @return Immutable iteration of path arguments.
137      */
138     public abstract List<PathArgument> getPathArguments();
139
140     /**
141      * Returns an iterable of path arguments in reverse order. This is useful
142      * when walking up a tree organized this way.
143      *
144      * @return Immutable iterable of path arguments in reverse order.
145      */
146     public abstract List<PathArgument> getReversePathArguments();
147
148     /**
149      * Returns the last PathArgument. This is equivalent of iterating
150      * to the last element of the iterable returned by {@link #getPathArguments()}.
151      *
152      * @return The last past argument, or null if there are no PathArguments.
153      */
154     public abstract PathArgument getLastPathArgument();
155
156     public static YangInstanceIdentifier create(final Iterable<? extends PathArgument> path) {
157         if (Iterables.isEmpty(path)) {
158             return EMPTY;
159         }
160
161         final HashCodeBuilder<PathArgument> hash = new HashCodeBuilder<>();
162         for (PathArgument a : path) {
163             hash.addArgument(a);
164         }
165
166         return FixedYangInstanceIdentifier.create(path, hash.build());
167     }
168
169     public static YangInstanceIdentifier create(final PathArgument... path) {
170         // We are forcing a copy, since we cannot trust the user
171         return create(Arrays.asList(path));
172     }
173
174     boolean pathArgumentsEqual(final YangInstanceIdentifier other) {
175         return Iterables.elementsEqual(getPathArguments(), other.getPathArguments());
176     }
177
178     @Override
179     public boolean equals(final Object obj) {
180         if (this == obj) {
181             return true;
182         }
183         if (!(obj instanceof YangInstanceIdentifier)) {
184             return false;
185         }
186         YangInstanceIdentifier other = (YangInstanceIdentifier) obj;
187         if (this.hashCode() != obj.hashCode()) {
188             return false;
189         }
190
191         return pathArgumentsEqual(other);
192     }
193
194     /**
195      * Constructs a new Instance Identifier with new {@link NodeIdentifier} added to the end of path arguments.
196      *
197      * @param name QName of {@link NodeIdentifier}
198      * @return Instance Identifier with additional path argument added to the end.
199      */
200     public final YangInstanceIdentifier node(final QName name) {
201         return node(new NodeIdentifier(name));
202     }
203
204     /**
205      * Constructs a new Instance Identifier with new {@link PathArgument} added to the end of path arguments.
206      *
207      * @param arg Path argument which should be added to the end
208      * @return Instance Identifier with additional path argument added to the end.
209      */
210     public final YangInstanceIdentifier node(final PathArgument arg) {
211         return new StackedYangInstanceIdentifier(this, arg, HashCodeBuilder.nextHashCode(hash, arg));
212     }
213
214     /**
215      * Get the relative path from an ancestor. This method attempts to perform
216      * the reverse of concatenating a base (ancestor) and a path.
217      *
218      * @param ancestor
219      *            Ancestor against which the relative path should be calculated
220      * @return This object's relative path from parent, or Optional.absent() if
221      *         the specified parent is not in fact an ancestor of this object.
222      */
223     public Optional<YangInstanceIdentifier> relativeTo(final YangInstanceIdentifier ancestor) {
224         if (this == ancestor) {
225             return Optional.of(EMPTY);
226         }
227         if (ancestor.isEmpty()) {
228             return Optional.of(this);
229         }
230
231         final Iterator<?> lit = getPathArguments().iterator();
232         final Iterator<?> oit = ancestor.getPathArguments().iterator();
233         int common = 0;
234
235         while (oit.hasNext()) {
236             // Ancestor is not really an ancestor
237             if (!lit.hasNext() || !lit.next().equals(oit.next())) {
238                 return Optional.absent();
239             }
240
241             ++common;
242         }
243
244         if (common == 0) {
245             return Optional.of(this);
246         }
247         if (!lit.hasNext()) {
248             return Optional.of(EMPTY);
249         }
250
251         return Optional.of(createRelativeIdentifier(common));
252     }
253
254     @Override
255     public final boolean contains(@Nonnull final YangInstanceIdentifier other) {
256         if (this == other) {
257             return true;
258         }
259
260         Preconditions.checkArgument(other != null, "other should not be null");
261         final Iterator<?> lit = getPathArguments().iterator();
262         final Iterator<?> oit = other.getPathArguments().iterator();
263
264         while (lit.hasNext()) {
265             if (!oit.hasNext()) {
266                 return false;
267             }
268
269             if (!lit.next().equals(oit.next())) {
270                 return false;
271             }
272         }
273
274         return true;
275     }
276
277     @Override
278     public final String toString() {
279         /*
280          * The toStringCache is safe, since the object contract requires
281          * immutability of the object and all objects referenced from this
282          * object.
283          * Used lists, maps are immutable. Path Arguments (elements) are also
284          * immutable, since the PathArgument contract requires immutability.
285          * The cache is thread-safe - if multiple computations occurs at the
286          * same time, cache will be overwritten with same result.
287          */
288         String ret = toStringCache;
289         if (ret == null) {
290             final StringBuilder builder = new StringBuilder("/");
291             PathArgument prev = null;
292             for (PathArgument argument : getPathArguments()) {
293                 if (prev != null) {
294                     builder.append('/');
295                 }
296                 builder.append(argument.toRelativeString(prev));
297                 prev = argument;
298             }
299
300             ret = builder.toString();
301             TOSTRINGCACHE_UPDATER.lazySet(this, ret);
302         }
303         return ret;
304     }
305
306     @Override
307     public final int hashCode() {
308         /*
309          * The caching is safe, since the object contract requires
310          * immutability of the object and all objects referenced from this
311          * object.
312          * Used lists, maps are immutable. Path Arguments (elements) are also
313          * immutable, since the PathArgument contract requires immutability.
314          */
315         return hash;
316     }
317
318     private static int hashCode(final Object value) {
319         if (value == null) {
320             return 0;
321         }
322
323         if (byte[].class.equals(value.getClass())) {
324             return Arrays.hashCode((byte[]) value);
325         }
326
327         if (value.getClass().isArray()) {
328             int hash = 0;
329             int length = Array.getLength(value);
330             for (int i = 0; i < length; i++) {
331                 hash += Objects.hashCode(Array.get(value, i));
332             }
333
334             return hash;
335         }
336
337         return Objects.hashCode(value);
338     }
339
340     // Static factories & helpers
341
342     /**
343      * Returns a new InstanceIdentifier with only one path argument of type {@link NodeIdentifier} with supplied
344      * QName.
345      *
346      * @param name QName of first node identifier
347      * @return Instance Identifier with only one path argument of type {@link NodeIdentifier}
348      */
349     public static YangInstanceIdentifier of(final QName name) {
350         return create(new NodeIdentifier(name));
351     }
352
353     /**
354      * Returns new builder for InstanceIdentifier with empty path arguments.
355      *
356      * @return new builder for InstanceIdentifier with empty path arguments.
357      */
358     public static InstanceIdentifierBuilder builder() {
359         return new YangInstanceIdentifierBuilder();
360     }
361
362     /**
363      * Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.
364      *
365      * @param origin InstanceIdentifier from which path arguments are copied.
366      * @return new builder for InstanceIdentifier with path arguments copied from original instance identifier.
367      */
368     public static InstanceIdentifierBuilder builder(final YangInstanceIdentifier origin) {
369         return new YangInstanceIdentifierBuilder(origin.getPathArguments(), origin.hashCode());
370     }
371
372     /**
373      * Path argument / component of InstanceIdentifier.
374      * Path argument uniquely identifies node in data tree on particular
375      * level.
376      *
377      * <p>
378      * This interface itself is used as common parent for actual
379      * path arguments types and should not be implemented by user code.
380      *
381      * <p>
382      * Path arguments SHOULD contain only minimum of information
383      * required to uniquely identify node on particular subtree level.
384      *
385      * <p>
386      * For actual path arguments types see:
387      * <ul>
388      * <li>{@link NodeIdentifier} - Identifier of container or leaf
389      * <li>{@link NodeIdentifierWithPredicates} - Identifier of list entries, which have key defined
390      * <li>{@link AugmentationIdentifier} - Identifier of augmentation
391      * <li>{@link NodeWithValue} - Identifier of leaf-list entry
392      * </ul>
393      */
394     public interface PathArgument extends Comparable<PathArgument>, Immutable, Serializable {
395         /**
396          * If applicable returns unique QName of data node as defined in YANG
397          * Schema.
398          *
399          * <p>
400          * This method may return null, if the corresponding schema node, does
401          * not have QName associated, such as in cases of augmentations.
402          *
403          * @return Node type
404          */
405         QName getNodeType();
406
407         /**
408          * Return the string representation of this object for use in context
409          * provided by a previous object. This method can be implemented in
410          * terms of {@link #toString()}, but implementations are encourage to
411          * reuse any context already emitted by the previous object.
412          *
413          * @param previous Previous path argument
414          * @return String representation
415          */
416         String toRelativeString(PathArgument previous);
417     }
418
419     private abstract static class AbstractPathArgument implements PathArgument {
420         private static final long serialVersionUID = -4546547994250849340L;
421         private final QName nodeType;
422         private transient int hashValue;
423         private transient volatile boolean hashGuard = false;
424
425         protected AbstractPathArgument(final QName nodeType) {
426             this.nodeType = Preconditions.checkNotNull(nodeType);
427         }
428
429         @Override
430         public final QName getNodeType() {
431             return nodeType;
432         }
433
434         @Override
435         @SuppressWarnings("checkstyle:parameterName")
436         public int compareTo(@Nonnull final PathArgument o) {
437             return nodeType.compareTo(o.getNodeType());
438         }
439
440         protected int hashCodeImpl() {
441             return 31 + getNodeType().hashCode();
442         }
443
444         @Override
445         public final int hashCode() {
446             if (!hashGuard) {
447                 hashValue = hashCodeImpl();
448                 hashGuard = true;
449             }
450
451             return hashValue;
452         }
453
454         @Override
455         public boolean equals(final Object obj) {
456             if (this == obj) {
457                 return true;
458             }
459             if (obj == null || this.getClass() != obj.getClass()) {
460                 return false;
461             }
462
463             return getNodeType().equals(((AbstractPathArgument)obj).getNodeType());
464         }
465
466         @Override
467         public String toString() {
468             return getNodeType().toString();
469         }
470
471         @Override
472         public String toRelativeString(final PathArgument previous) {
473             if (previous instanceof AbstractPathArgument) {
474                 final QNameModule mod = previous.getNodeType().getModule();
475                 if (getNodeType().getModule().equals(mod)) {
476                     return getNodeType().getLocalName();
477                 }
478             }
479
480             return getNodeType().toString();
481         }
482     }
483
484     /**
485      * Simple path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.ContainerNode} or
486      * {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} leaf in particular subtree.
487      */
488     public static final class NodeIdentifier extends AbstractPathArgument {
489         private static final long serialVersionUID = -2255888212390871347L;
490         private static final LoadingCache<QName, NodeIdentifier> CACHE = CacheBuilder.newBuilder().weakValues()
491                 .build(new CacheLoader<QName, NodeIdentifier>() {
492                     @Override
493                     public NodeIdentifier load(@Nonnull final QName key) {
494                         return new NodeIdentifier(key);
495                     }
496                 });
497
498         public NodeIdentifier(final QName node) {
499             super(node);
500         }
501
502         /**
503          * Return a NodeIdentifier for a particular QName. Unlike the constructor, this factory method uses a global
504          * instance cache, resulting in object reuse for equal inputs.
505          *
506          * @param node Node's QName
507          * @return A {@link NodeIdentifier}
508          */
509         public static NodeIdentifier create(final QName node) {
510             return CACHE.getUnchecked(node);
511         }
512     }
513
514     /**
515      * Composite path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode} leaf
516      * overall data tree.
517      */
518     public static final class NodeIdentifierWithPredicates extends AbstractPathArgument {
519         private static final long serialVersionUID = -4787195606494761540L;
520
521         private final Map<QName, Object> keyValues;
522
523         public NodeIdentifierWithPredicates(final QName node, final Map<QName, Object> keyValues) {
524             super(node);
525             // Retains ImmutableMap for empty maps. For larger sizes uses a shared key set.
526             this.keyValues = ImmutableOffsetMap.unorderedCopyOf(keyValues);
527         }
528
529         public NodeIdentifierWithPredicates(final QName node, final QName key, final Object value) {
530             super(node);
531             this.keyValues = SharedSingletonMap.unorderedOf(key, value);
532         }
533
534         public Map<QName, Object> getKeyValues() {
535             return keyValues;
536         }
537
538         @Override
539         protected int hashCodeImpl() {
540             final int prime = 31;
541             int result = super.hashCodeImpl();
542             result = prime * result;
543
544             for (Entry<QName, Object> entry : keyValues.entrySet()) {
545                 result += Objects.hashCode(entry.getKey()) + YangInstanceIdentifier.hashCode(entry.getValue());
546             }
547             return result;
548         }
549
550         @Override
551         @SuppressWarnings("checkstyle:equalsHashCode")
552         public boolean equals(final Object obj) {
553             if (!super.equals(obj)) {
554                 return false;
555             }
556
557             final Map<QName, Object> otherKeyValues = ((NodeIdentifierWithPredicates) obj).keyValues;
558
559             // TODO: benchmark to see if just calling equals() on the two maps is not faster
560             if (keyValues == otherKeyValues) {
561                 return true;
562             }
563             if (keyValues.size() != otherKeyValues.size()) {
564                 return false;
565             }
566
567             for (Entry<QName, Object> entry : keyValues.entrySet()) {
568                 if (!otherKeyValues.containsKey(entry.getKey())
569                         || !Objects.deepEquals(entry.getValue(), otherKeyValues.get(entry.getKey()))) {
570
571                     return false;
572                 }
573             }
574
575             return true;
576         }
577
578         @Override
579         public String toString() {
580             return super.toString() + '[' + keyValues + ']';
581         }
582
583         @Override
584         public String toRelativeString(final PathArgument previous) {
585             return super.toRelativeString(previous) + '[' + keyValues + ']';
586         }
587     }
588
589     /**
590      * Simple path argument identifying a {@link LeafSetEntryNode} leaf
591      * overall data tree.
592      */
593     public static final class NodeWithValue<T> extends AbstractPathArgument {
594         private static final long serialVersionUID = -3637456085341738431L;
595
596         private final T value;
597
598         public NodeWithValue(final QName node, final T value) {
599             super(node);
600             this.value = value;
601         }
602
603         public T getValue() {
604             return value;
605         }
606
607         @Override
608         protected int hashCodeImpl() {
609             final int prime = 31;
610             int result = super.hashCodeImpl();
611             result = prime * result + YangInstanceIdentifier.hashCode(value);
612             return result;
613         }
614
615         @Override
616         @SuppressWarnings("checkstyle:equalsHashCode")
617         public boolean equals(final Object obj) {
618             if (!super.equals(obj)) {
619                 return false;
620             }
621             final NodeWithValue<?> other = (NodeWithValue<?>) obj;
622             return Objects.deepEquals(value, other.value);
623         }
624
625         @Override
626         public String toString() {
627             return super.toString() + '[' + value + ']';
628         }
629
630         @Override
631         public String toRelativeString(final PathArgument previous) {
632             return super.toRelativeString(previous) + '[' + value + ']';
633         }
634     }
635
636     /**
637      * Composite path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode}
638      * node in particular subtree.
639      *
640      * <p>
641      * Augmentation is uniquely identified by set of all possible child nodes.
642      * This is possible
643      * to identify instance of augmentation,
644      * since RFC6020 states that <code>augment</code> that augment
645      * statement must not add multiple nodes from same namespace
646      * / module to the target node.
647      *
648      * @see <a href="http://tools.ietf.org/html/rfc6020#section-7.15">RFC6020</a>
649      */
650     public static final class AugmentationIdentifier implements PathArgument {
651         private static final long serialVersionUID = -8122335594681936939L;
652         private final ImmutableSet<QName> childNames;
653
654         @Override
655         public QName getNodeType() {
656             // This should rather throw exception than return always null
657             throw new UnsupportedOperationException("Augmentation node has no QName");
658         }
659
660         /**
661          * Construct new augmentation identifier using supplied set of possible
662          * child nodes.
663          *
664          * @param childNames
665          *            Set of possible child nodes.
666          */
667         public AugmentationIdentifier(final Set<QName> childNames) {
668             this.childNames = ImmutableSet.copyOf(childNames);
669         }
670
671         /**
672          * Returns set of all possible child nodes.
673          *
674          * @return set of all possible child nodes.
675          */
676         public Set<QName> getPossibleChildNames() {
677             return childNames;
678         }
679
680         @Override
681         public String toString() {
682             return "AugmentationIdentifier{" + "childNames=" + childNames + '}';
683         }
684
685         @Override
686         public String toRelativeString(final PathArgument previous) {
687             return toString();
688         }
689
690         @Override
691         public boolean equals(final Object obj) {
692             if (this == obj) {
693                 return true;
694             }
695             if (!(obj instanceof AugmentationIdentifier)) {
696                 return false;
697             }
698
699             AugmentationIdentifier that = (AugmentationIdentifier) obj;
700             return childNames.equals(that.childNames);
701         }
702
703         @Override
704         public int hashCode() {
705             return childNames.hashCode();
706         }
707
708         @Override
709         @SuppressWarnings("checkstyle:parameterName")
710         public int compareTo(@Nonnull final PathArgument o) {
711             if (!(o instanceof AugmentationIdentifier)) {
712                 return -1;
713             }
714             AugmentationIdentifier other = (AugmentationIdentifier) o;
715             Set<QName> otherChildNames = other.getPossibleChildNames();
716             int thisSize = childNames.size();
717             int otherSize = otherChildNames.size();
718             if (thisSize == otherSize) {
719                 Iterator<QName> otherIterator = otherChildNames.iterator();
720                 for (QName name : childNames) {
721                     int child = name.compareTo(otherIterator.next());
722                     if (child != 0) {
723                         return child;
724                     }
725                 }
726                 return 0;
727             } else if (thisSize < otherSize) {
728                 return 1;
729             } else {
730                 return -1;
731             }
732         }
733     }
734
735     /**
736      * Fluent Builder of Instance Identifier instances.
737      */
738     public interface InstanceIdentifierBuilder extends Builder<YangInstanceIdentifier> {
739         /**
740          * Adds a {@link PathArgument} to to path arguments of resulting instance identifier.
741          *
742          * @param arg A {@link PathArgument} to be added
743          * @return this builder
744          */
745         InstanceIdentifierBuilder node(PathArgument arg);
746
747         /**
748          * Adds {@link NodeIdentifier} with supplied QName to path arguments of resulting instance identifier.
749          *
750          * @param nodeType QName of {@link NodeIdentifier} which will be added
751          * @return this builder
752          */
753         InstanceIdentifierBuilder node(QName nodeType);
754
755         /**
756          * Adds {@link NodeIdentifierWithPredicates} with supplied QName and key values to path arguments of resulting
757          * instance identifier.
758          *
759          * @param nodeType QName of {@link NodeIdentifierWithPredicates} which will be added
760          * @param keyValues Map of key components and their respective values for {@link NodeIdentifierWithPredicates}
761          * @return this builder
762          */
763         InstanceIdentifierBuilder nodeWithKey(QName nodeType, Map<QName, Object> keyValues);
764
765         /**
766          * Adds {@link NodeIdentifierWithPredicates} with supplied QName and key, value.
767          *
768          * @param nodeType QName of {@link NodeIdentifierWithPredicates} which will be added
769          * @param key QName of key which will be added
770          * @param value value of key which will be added
771          * @return this builder
772          */
773         InstanceIdentifierBuilder nodeWithKey(QName nodeType, QName key, Object value);
774
775         /**
776          * Builds an {@link YangInstanceIdentifier} with path arguments from this builder.
777          *
778          * @return {@link YangInstanceIdentifier}
779          */
780         @Override
781         YangInstanceIdentifier build();
782     }
783 }