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