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