Shift Builder<P> from toInstance() to build() 92/14092/2
authorEd Warnicke <eaw@cisco.com>
Mon, 12 Jan 2015 00:25:53 +0000 (18:25 -0600)
committerEd Warnicke <eaw@cisco.com>
Thu, 15 Jan 2015 13:16:00 +0000 (07:16 -0600)
In order to be able to use Builder<P> as a marker
on generated Builders, it needed to shift to build()

All 'internal' uses for Builder have been changed
to use build().  For things used outside of yangtools,
a depracted toInstance() is maintained on child
interfaces/classes.

Change-Id: I43662296e328133a5b5267be54d407e2ad4b95e8
Signed-off-by: Ed Warnicke <eaw@cisco.com>
30 files changed:
code-generator/binding-data-codec/src/test/java/org/opendaylight/yangtools/binding/data/codec/test/AugmentationSubstitutionTest.java
code-generator/binding-data-codec/src/test/java/org/opendaylight/yangtools/binding/data/codec/test/CaseSubstitutionTest.java
code-generator/binding-data-codec/src/test/java/org/opendaylight/yangtools/binding/data/codec/test/EmptyLeafTest.java
code-generator/binding-data-codec/src/test/java/org/opendaylight/yangtools/binding/data/codec/test/InstanceIdentifierSerializeDeserializeTest.java
code-generator/binding-data-codec/src/test/java/org/opendaylight/yangtools/binding/data/codec/test/InstanceIdentifierTest.java
code-generator/binding-data-codec/src/test/java/org/opendaylight/yangtools/binding/data/codec/test/LeafReferenceTest.java
code-generator/binding-data-codec/src/test/java/org/opendaylight/yangtools/binding/data/codec/test/NormalizedNodeSerializeDeserializeTest.java
code-generator/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/yang/unified/doc/generator/GeneratorImpl.xtend
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Builder.java
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/CompositeObjectRegistration.java
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/ProductAwareBuilder.java
common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/spi/NoopObjectCache.java
common/util/src/main/java/org/opendaylight/yangtools/util/HashCodeBuilder.java
common/util/src/test/java/org/opendaylight/yangtools/util/HashCodeBuilderTest.java
integration-test/yang-runtime-tests/src/test/java/org/opendaylight/yangtools/it/yang/runtime/tests/BindingReadingTest.java
restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/Bug1196Test.java
restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/Bug527Test.java
restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/RestconfUtilsTest.java
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifierBuilderImpl.java
yang/yang-binding/src/test/java/org/opendaylight/yangtools/yang/binding/test/InstanceIdentifierTest.java
yang/yang-binding/src/test/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtilTest.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifier.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java
yang/yang-data-composite-node/src/main/java/org/opendaylight/yangtools/yang/data/composite/node/schema/cnsn/serializer/ContainerNodeCnSnSerializer.java
yang/yang-data-composite-node/src/main/java/org/opendaylight/yangtools/yang/data/composite/node/schema/cnsn/serializer/MapEntryNodeCnSnSerializer.java
yang/yang-data-composite-node/src/test/java/org/opendaylight/yangtools/yang/data/composite/node/schema/TestUtils.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/ImmutableCompositeNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/util/NodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ConstraintsBuilderImpl.java

index 62d913f8b6ad11850238e13c03048a7a949d6f16..6dc53e5f8f522614859498069a79dd5dd496f488 100644 (file)
@@ -36,7 +36,7 @@ public class AugmentationSubstitutionTest extends AbstractBindingRuntimeTest {
 
     private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
     private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
-            .child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+            .child(TopLevelList.class, TOP_FOO_KEY).build();
     private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
             .augmentation(TreeLeafOnlyAugment.class);
     private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
index a01e12d1729701291baec3aef71d62ad8b42ccc9..c90a5a86be3066bb06c3919177a34d47aed6748a 100644 (file)
@@ -37,7 +37,7 @@ public class CaseSubstitutionTest extends AbstractBindingRuntimeTest {
 
     private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
     private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
-            .child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+            .child(TopLevelList.class, TOP_FOO_KEY).build();
     private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
             .augmentation(TreeLeafOnlyAugment.class);
     private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
index 53258f8e116b9d30a06920447df68043f3097c5d..26d9bbba21f4ad533efc561bbdf780f0047e5d57 100644 (file)
@@ -40,7 +40,7 @@ public class EmptyLeafTest extends AbstractBindingRuntimeTest {
 
     private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
     private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
-            .child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+            .child(TopLevelList.class, TOP_FOO_KEY).build();
     private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
             .augmentation(TreeLeafOnlyAugment.class);
     private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
index b0fca82863c6a8ca3553755be5e18135af5fd0df..b276bbd534ce608c2f5b660fc4d45f7de0f7aba3 100644 (file)
@@ -34,7 +34,7 @@ public class InstanceIdentifierSerializeDeserializeTest extends AbstractBindingR
 
     private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
     private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
-            .builder(Top.class).child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+            .builder(Top.class).child(TopLevelList.class, TOP_FOO_KEY).build();
     private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
             BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
     private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
index e011017894c3947bdaa3cf59805fe0b425927692..fa8b48a35b9744ff55ad965fe5f48633fc733beb 100644 (file)
@@ -31,7 +31,7 @@ public class InstanceIdentifierTest extends AbstractBindingRuntimeTest {
 
     private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
     private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
-            .child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+            .child(TopLevelList.class, TOP_FOO_KEY).build();
     private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
             .augmentation(TreeLeafOnlyAugment.class);
     private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
index ba8c84cd96a8c7e0617e44ef22e3a3df32216c23..10dce65e2750d5c67fb4dc27422b68b0f17849e0 100644 (file)
@@ -32,7 +32,7 @@ public class LeafReferenceTest extends AbstractBindingRuntimeTest {
 
     private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
     private static final InstanceIdentifier<TreeComplexLeaves> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
-            .child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeComplexLeaves.class).toInstance();
+            .child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeComplexLeaves.class).build();
 
     private BindingNormalizedNodeCodecRegistry registry;
 
index 4b08fbe17f5d3283f4748adc4dd9a48af7f90fca..f223bfef285a843a9446c4aebffa34d7bc7d463f 100644 (file)
@@ -79,7 +79,7 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingRunti
     private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
 
     private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
-            .builder(Top.class).child(TopLevelList.class, TOP_LEVEL_LIST_FOO_KEY).toInstance();
+            .builder(Top.class).child(TopLevelList.class, TOP_LEVEL_LIST_FOO_KEY).build();
     private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
             BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
     private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
index 672f26eb1e04f3087e3063f12e9d5b9aa12ec56c..62f628c50f5f23593d3672d948de69ad94d5a9f6 100644 (file)
@@ -754,7 +754,7 @@ class GeneratorImpl {
 
     def CharSequence tree(Module module) '''
         «strong(module.name)»
-        «module.childNodes.treeSet(YangInstanceIdentifier.builder.toInstance())»
+        «module.childNodes.treeSet(YangInstanceIdentifier.builder.build())»
     '''
 
     private def dispatch CharSequence tree(ChoiceNode node,YangInstanceIdentifier path) '''
@@ -794,7 +794,7 @@ class GeneratorImpl {
         «IF !childNodes.nullOrEmpty»
             <h2>Child nodes</h2>
 
-            «childNodes.printChildren(3,YangInstanceIdentifier.builder().toInstance())»
+            «childNodes.printChildren(3,YangInstanceIdentifier.builder().build())»
         «ENDIF»
     '''
 
index 0484c4831e86b81bcf7ebf408049dcdcc135d3e3..0cf4926f7956697b5621658d1d52e538d5f4d421 100644 (file)
@@ -9,20 +9,21 @@ package org.opendaylight.yangtools.concepts;
 
 /**
  * Builder object which produces a product.
- * 
+ *
  * @param <P> Product of builder
- * 
+ *
  * @author Tony Tkacik &lt;ttkacik@cisco.com&gt;
  */
 public interface Builder<P> extends Mutable {
-    
+
     /**
      * Returns instance of the product.
-     * 
+     *
      * Multiple calls to this method are not required to return
      * same instance if the state of the builder was changed.
-     * 
+     *
      * @return Newly-built instance
      */
-    P toInstance();
+    P build();
+
 }
index c999c5962be4d76e7efc16838afab86873bc7bf2..34bafc2dc1a285517c220bb22795e1a0e736e513 100644 (file)
@@ -67,8 +67,16 @@ public final class CompositeObjectRegistration<T> extends AbstractObjectRegistra
         }
 
         @Override
-        public CompositeObjectRegistration<T> toInstance() {
+        public CompositeObjectRegistration<T> build() {
             return new CompositeObjectRegistration<>(instance, registrations);
         }
+
+        /*
+         * @deprecated Use #build() instead.
+         */
+        @Deprecated
+        public CompositeObjectRegistration<T> toInstance() {
+            return build();
+        }
     }
 }
index 184e467d443c967ce2c7ae553e606184b59dc935..771ceb2cac976dc35addf4ed4f57620d1de1e6dd 100644 (file)
@@ -17,7 +17,7 @@ package org.opendaylight.yangtools.concepts;
 public interface ProductAwareBuilder<P> extends Builder<P> {
        /**
         * Return the hash code of the product. This has to be equivalent
-        * of calling {@link #toInstance()}.{@link Object#hashCode()}.
+        * of calling {@link #build()}.{@link Object#hashCode()}.
         *
         * @return the hash code of the product.
         */
@@ -26,7 +26,7 @@ public interface ProductAwareBuilder<P> extends Builder<P> {
        /**
         * Check whether an instance of the product that would be created
         * by the builder is equal to an existing instance. This has to
-        * be equivalent of calling {@link #toInstance()}.{@link Object#equals(Object)}.
+        * be equivalent of calling {@link #build()}.{@link Object#equals(Object)}.
         *
         * @param product Product instance
         * @return Return true if the product is equal to the would-be
index 11631993dad4a8fbab05f25ded5bd7e73aec602c..a44543bfb2014569676117ec53ed636a9cc528da 100644 (file)
@@ -38,6 +38,6 @@ public final class NoopObjectCache implements ObjectCache {
 
        @Override
        public <B extends ProductAwareBuilder<P>, P> P getProduct(final B builder) {
-               return builder.toInstance();
+               return builder.build();
        }
 }
index 874809f13c77e74dba17f1fa21ed9e1877ef64d1..99da089384286c1b009528c36cd27ff8d4fda459 100644 (file)
@@ -58,6 +58,11 @@ public final class HashCodeBuilder<T> implements Builder<Integer> {
     }
 
     @Override
+    public Integer build() {
+        return currentHash;
+    }
+
+    @Deprecated
     public Integer toInstance() {
         return currentHash;
     }
index dea857e1946f6ba7ed845c0323488991a297f353..1f7666a2b21f81dd55a8f6ef8f3c194d558e1c28 100644 (file)
@@ -16,12 +16,12 @@ public class HashCodeBuilderTest {
     @Test
     public void testAllMethodsOfHashCodeBuilder() {
         final HashCodeBuilder<String> hashCodeBuilder = new HashCodeBuilder<>();
-        assertEquals("Default hash code should be '1'.", 1, hashCodeBuilder.toInstance().intValue());
+        assertEquals("Default hash code should be '1'.", 1, hashCodeBuilder.build().intValue());
 
         int nextHashCode = HashCodeBuilder.nextHashCode(1, "test");
         assertEquals("Next hash code should be '3556529'.", 3556529, nextHashCode);
 
         hashCodeBuilder.addArgument("another test");
-        assertEquals("Updated internal hash code should be '700442706'.", -700442706, hashCodeBuilder.toInstance().intValue());
+        assertEquals("Updated internal hash code should be '700442706'.", -700442706, hashCodeBuilder.build().intValue());
     }
 }
index 4ce63b2b5b3bcb8b233cbfdfc3da5528f53faae5..89c67c81af9b3739022f2451a1a3d115c67a69af 100644 (file)
@@ -39,7 +39,7 @@ public class BindingReadingTest {
     private static final NodeId SOURCE_NODE_ID = new NodeId("node:id");
     private static final TpId SOURCE_TP_ID = new TpId("source:tp");
     private static final InstanceIdentifier<NetworkTopology> NETWORK_TOPOLOGY_PATH = InstanceIdentifier.builder(
-            NetworkTopology.class).toInstance();
+            NetworkTopology.class).build();
     private NetworkTopology networkModel;
     private Link linkModel;
 
index 20c68aeb31e7cb5ca107a1c858ac3141edebeacf..7b8be180a53b50a61c781eb0750e37529d167b91 100644 (file)
@@ -63,7 +63,7 @@ public class Bug1196Test {
     @Test
     public void testXmlDataToDataObjectLinuxCase() {
         final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+                .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).build();
         final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-linux.xml");
         final DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
                 this.mappingService.getSchemaContext()).getValue();
@@ -98,7 +98,7 @@ public class Bug1196Test {
     @Test
     public void testXmlDataToDataObjectUnixCase() {
         final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+                .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).build();
         final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-unix.xml");
         final DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
                 this.mappingService.getSchemaContext()).getValue();
index 6d66f9261f61807c34e7a42a7ee509a1b58aa7f3..97a47cb2753091f530c1152850cc8ea871668ba8 100644 (file)
@@ -55,7 +55,7 @@ public class Bug527Test {
 
     @Test
     public void testToDataObjectMappingWithNestedAugmentations() {
-        InstanceIdentifier<Factory> factoryId = InstanceIdentifier.builder(Factory.class).toInstance();
+        InstanceIdentifier<Factory> factoryId = InstanceIdentifier.builder(Factory.class).build();
         InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug527.xml");
         DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(factoryId, mappingService,
                 mappingService.getSchemaContext()).getValue();
index dc79f118c38ad079053d600af7d2c7798655aded..a327389ef3f8961c97e9c817f1c474d043b0fd89 100644 (file)
@@ -45,7 +45,7 @@ public class RestconfUtilsTest {
     @Test
     public void firstTest() { // test static state collisions with the other test
         final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+                .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).build();
         final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-linux.xml");
         RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
                 this.mappingService.getSchemaContext()).getValue();
index 934c90d9ae77aea68079ad3b0a91eb6489dda1bc..087a92c64b91f3de084af846306b6717ccca0bc0 100644 (file)
@@ -430,7 +430,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
         }
         Preconditions.checkArgument(a != null, "pathArguments may not be empty");
 
-        return trustedCreate(a, pathArguments, hashBuilder.toInstance(), wildcard);
+        return trustedCreate(a, pathArguments, hashBuilder.build(), wildcard);
     }
 
     /**
@@ -667,6 +667,12 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
          * @return
          */
         InstanceIdentifier<T> build();
+
+        /*
+         * @deprecated use #build()
+         */
+        @Deprecated
+        InstanceIdentifier<T> toInstance();
     }
 
     private void writeObject(final java.io.ObjectOutputStream out) throws IOException {
index 3ba833d2f471f4c9563d551796fb34114d9faa6f..5be717b574dbba76ea56458a0bb95fb8e7dd8bf0 100644 (file)
@@ -37,7 +37,7 @@ final class InstanceIdentifierBuilderImpl<T extends DataObject> implements Insta
 
     @Override
     public int hashCode() {
-        return hashBuilder.toInstance();
+        return hashBuilder.build();
     }
 
     @SuppressWarnings("unchecked")
@@ -96,11 +96,14 @@ final class InstanceIdentifierBuilderImpl<T extends DataObject> implements Insta
         }
 
         @SuppressWarnings("unchecked")
-        final InstanceIdentifier<T> ret = (InstanceIdentifier<T>) InstanceIdentifier.trustedCreate(arg, pathArguments, hashBuilder.toInstance(), wildcard);
+        final InstanceIdentifier<T> ret = (InstanceIdentifier<T>) InstanceIdentifier.trustedCreate(arg, pathArguments, hashBuilder.build(), wildcard);
         return ret;
     }
 
-    @Override
+    /*
+     * @deprecated Use #build() instead.
+     */
+    @Deprecated
     public InstanceIdentifier<T> toInstance() {
         return build();
     }
index e4188b470da3722e6004c114207d3954c80260aa..34e3911516cdb5ea35494ab5dfbd9ad304019f85 100644 (file)
@@ -27,13 +27,13 @@ public class InstanceIdentifierTest {
     @Test
     public void constructWithPredicates() {
 
-        InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).toInstance();
+        InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
 
         assertNotNull(nodes);
         assertEquals(Nodes.class, nodes.getTargetType());
 
 
-        InstanceIdentifier<Node> node = nodes.builder().child(Node.class).toInstance();
+        InstanceIdentifier<Node> node = nodes.builder().child(Node.class).build();
 
         assertNotNull(node);
         assertEquals(Node.class, node.getTargetType());
@@ -44,8 +44,8 @@ public class InstanceIdentifierTest {
     @Test
     public void fluentConstruction() {
 
-        InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).toInstance();
-        InstanceIdentifier<Node> node = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).toInstance();
+        InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
+        InstanceIdentifier<Node> node = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build();
 
         assertNotNull(node);
         assertEquals(Node.class, node.getTargetType());
@@ -59,10 +59,10 @@ public class InstanceIdentifierTest {
         InstanceIdentifier<FooChild> fooChild = InstanceIdentifier.builder(Nodes.class).child(InstantiatedFoo.class).child(FooChild.class).build();
 
         InstanceIdentifier<Node> nodeTen = InstanceIdentifier.builder(Nodes.class) //
-                .child(Node.class,new NodeKey(10)).toInstance();
+                .child(Node.class,new NodeKey(10)).build();
         InstanceIdentifier<Node> nodeOne = InstanceIdentifier.builder(Nodes.class) //
-                .child(Node.class,new NodeKey(1)).toInstance();
-        InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).toInstance();
+                .child(Node.class,new NodeKey(1)).build();
+        InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
 
         assertFalse(fooChild.contains(nodeTen));
         assertFalse(nodeTen.contains(nodes));
@@ -73,7 +73,7 @@ public class InstanceIdentifierTest {
 
     @Test
     public void containsWildcarded() {
-        InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).toInstance();
+        InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
         InstanceIdentifier<Node> wildcarded = InstanceIdentifier.builder(Nodes.class).child(Node.class).build();
         InstanceIdentifier<NodeChild> wildcardedChildren = InstanceIdentifier.builder(Nodes.class) //
                 .child(Node.class) //
@@ -84,9 +84,9 @@ public class InstanceIdentifierTest {
 
 
         InstanceIdentifier<Node> nodeTen = InstanceIdentifier.builder(Nodes.class) //
-                .child(Node.class,new NodeKey(10)).toInstance();
+                .child(Node.class,new NodeKey(10)).build();
         InstanceIdentifier<Node> nodeOne = InstanceIdentifier.builder(Nodes.class) //
-                .child(Node.class,new NodeKey(1)).toInstance();
+                .child(Node.class,new NodeKey(1)).build();
 
         assertFalse(nodeTen.isWildcarded());
         assertFalse(nodeOne.isWildcarded());
@@ -96,14 +96,14 @@ public class InstanceIdentifierTest {
 
 
         InstanceIdentifier<NodeChild> nodeTenChildWildcarded = InstanceIdentifier.builder(Nodes.class) //
-                .child(Node.class,new NodeKey(10)).child(NodeChild.class).toInstance();
+                .child(Node.class,new NodeKey(10)).child(NodeChild.class).build();
 
         assertTrue(nodeTenChildWildcarded.isWildcarded());
 
         InstanceIdentifier<NodeChild> nodeTenChild = InstanceIdentifier.builder(Nodes.class) //
-                .child(Node.class,new NodeKey(10)).child(NodeChild.class, new NodeChildKey(10)).toInstance();
+                .child(Node.class,new NodeKey(10)).child(NodeChild.class, new NodeChildKey(10)).build();
         InstanceIdentifier<NodeChild> nodeOneChild = InstanceIdentifier.builder(Nodes.class) //
-                .child(Node.class,new NodeKey(1)).child(NodeChild.class, new NodeChildKey(1)).toInstance();
+                .child(Node.class,new NodeKey(1)).child(NodeChild.class, new NodeChildKey(1)).build();
 
 
         assertFalse(nodeTenChildWildcarded.containsWildcarded(nodeOneChild));
index e2400f9f3d5c2d30d1640ea11fc9bfe16a0bc81a..29dc602f60122400635544c92c0d462f95ff89ad 100644 (file)
@@ -33,7 +33,7 @@ public class DataObjectReadingUtilTest {
     public void setup() {
         MockitoAnnotations.initMocks(this);
 
-        path = InstanceIdentifier.builder(Nodes.class).toInstance();
+        path = InstanceIdentifier.builder(Nodes.class).build();
         ImmutableMap map = ImmutableMap.<InstanceIdentifier<? extends DataObject>,
                 DataObject>builder().put(path, mockedDataObject).build();
 
index c882db6693bb9b2a9b97ecb31650f8d95c94004f..d23b853df2f02f3c559c6c7fc81edc613ca9028a 100644 (file)
@@ -161,7 +161,7 @@ public final class YangInstanceIdentifier implements Path<YangInstanceIdentifier
             hash.addArgument(a);
         }
 
-        return new YangInstanceIdentifier(path, hash.toInstance());
+        return new YangInstanceIdentifier(path, hash.build());
     }
 
     public static final YangInstanceIdentifier create(final Iterable<? extends PathArgument> path) {
@@ -468,6 +468,12 @@ public final class YangInstanceIdentifier implements Path<YangInstanceIdentifier
          * @return {@link YangInstanceIdentifier}
          */
         YangInstanceIdentifier build();
+
+        /*
+         * @deprecated use #build()
+         */
+        @Deprecated
+        YangInstanceIdentifier toInstance();
     }
 
     /**
@@ -734,7 +740,6 @@ public final class YangInstanceIdentifier implements Path<YangInstanceIdentifier
             return this;
         }
 
-        @Override
         @Deprecated
         public YangInstanceIdentifier toInstance() {
             return build();
@@ -742,7 +747,7 @@ public final class YangInstanceIdentifier implements Path<YangInstanceIdentifier
 
         @Override
         public YangInstanceIdentifier build() {
-            return new YangInstanceIdentifier(ImmutableList.copyOf(path), hash.toInstance());
+            return new YangInstanceIdentifier(ImmutableList.copyOf(path), hash.build());
         }
     }
 
index 1038ce883db6d8389f6ed15a77cc243b05011e0a..71a2b99e7f9f914cac06c50fcfdb8480d2981c8c 100644 (file)
@@ -257,14 +257,14 @@ public class TestingNormalizedNodeStructuresCreator {
         SimpleNode<?> anyxmlInData = NodeFactory.createImmutableSimpleNode(
                 QName.create("ns:complex:json", "2014-08-11", "anyxml-in-data"), null, "foo");
         return ImmutableCompositeNode.builder().add(anyxmlInData)
-                .setQName(QName.create("ns:complex:json", "2014-08-11", "lf12-any")).toInstance();
+                .setQName(QName.create("ns:complex:json", "2014-08-11", "lf12-any")).build();
     }
 
     private static CompositeNode prepareLf13Value() {
         SimpleNode<?> anyxmlInData = NodeFactory.createImmutableSimpleNode(
                 QName.create("ns:complex:json", "2014-08-11", "anyxml-in-data"), null, "foo");
         return ImmutableCompositeNode.builder().add(anyxmlInData)
-                .setQName(QName.create("ns:complex:json", "2014-08-11", "lf13-any")).toInstance();
+                .setQName(QName.create("ns:complex:json", "2014-08-11", "lf13-any")).build();
     }
 
     public static NormalizedNode<?, ?> leafNodeInContainer() {
index 7c2386b39878b933c67083160dd447a11cb373f4..ddba0e1f2294b8825b27049e23357d69864e152d 100644 (file)
@@ -31,7 +31,7 @@ public class ContainerNodeCnSnSerializer extends ContainerNodeBaseSerializer<Nod
         CompositeNodeBuilder<ImmutableCompositeNode> compNodeBuilder = ImmutableCompositeNode.builder();
         compNodeBuilder.setQName(node.getNodeType());
         compNodeBuilder.addAll(super.serialize(schema, node));
-        return Collections.<Node<?>> singletonList(compNodeBuilder.toInstance());        
+        return Collections.<Node<?>> singletonList(compNodeBuilder.build());
     }
 
     @Override
index 5adbd11e9e125a4f4cd6216eb7d11caac14a162c..1cadd4c6f36056d45bb727c001140e3585b8cc1d 100644 (file)
@@ -31,7 +31,7 @@ public class MapEntryNodeCnSnSerializer extends MapEntryNodeBaseSerializer<Node<
         CompositeNodeBuilder<ImmutableCompositeNode> compNodeBuilder = ImmutableCompositeNode.builder();
         compNodeBuilder.setQName(node.getNodeType());
         compNodeBuilder.addAll(super.serialize(schema, node));
-        return Collections.<Node<?>> singletonList(compNodeBuilder.toInstance());        
+        return Collections.<Node<?>> singletonList(compNodeBuilder.build());
     }
 
     @Override
index d2d2a3de3ac3bf5a926dd7edd27aeac45d97da97..58c28a8c38adf69fa9195b76615afd3681db17fd 100644 (file)
@@ -128,27 +128,27 @@ public class TestUtils {
         contBuilder.setQName(QName.create(MODULE_BASE, "cont"));
 
         // cont1
-        contBuilder.add(ImmutableCompositeNode.builder().setQName(QName.create(MODULE_BASE, "cont1")).toInstance());
+        contBuilder.add(ImmutableCompositeNode.builder().setQName(QName.create(MODULE_BASE, "cont1")).build());
 
         // cont2
         CompositeNodeBuilder<ImmutableCompositeNode> cont2 = ImmutableCompositeNode.builder().setQName(
                 QName.create(MODULE_BASE, "cont2"));
         cont2.add(createMutableSimpleNode(QName.create(MODULE_BASE, "lf21"), null, "value in cont2/lf21", null, null));
-        contBuilder.add(cont2.toInstance());
+        contBuilder.add(cont2.build());
 
         // lst1
-        contBuilder.add(ImmutableCompositeNode.builder().setQName(QName.create(MODULE_BASE, "lst1")).toInstance());
+        contBuilder.add(ImmutableCompositeNode.builder().setQName(QName.create(MODULE_BASE, "lst1")).build());
 
         // lst2
         CompositeNodeBuilder<ImmutableCompositeNode> lst2_1Builder = ImmutableCompositeNode.builder().setQName(
                 QName.create(MODULE_BASE, "lst2"));
         lst2_1Builder.add(createMutableSimpleNode(QName.create(MODULE_BASE, "lf21"), null, "some value21", null, null));
-        contBuilder.add(lst2_1Builder.toInstance());
+        contBuilder.add(lst2_1Builder.build());
 
         CompositeNodeBuilder<ImmutableCompositeNode> lst2_2Builder = ImmutableCompositeNode.builder().setQName(
                 QName.create(MODULE_BASE, "lst2"));
         lst2_2Builder.add(createMutableSimpleNode(QName.create(MODULE_BASE, "lf22"), null, "some value22", null, null));
-        contBuilder.add(lst2_2Builder.toInstance());
+        contBuilder.add(lst2_2Builder.build());
 
         // lflst1
         contBuilder.add(createMutableSimpleNode(QName.create(MODULE_BASE, "lflst1"), null, "lflst1_1", null, null));
@@ -166,19 +166,19 @@ public class TestUtils {
                 QName.create(MODULE_AUGMENT, "cont3"));
         cont3Builder.add(createMutableSimpleNode(QName.create(MODULE_AUGMENT, "lf31"), null,
                 "value in leaf in augment", null, null));
-        contBuilder.add(cont3Builder.toInstance());
+        contBuilder.add(cont3Builder.build());
 
         // anxml-composite
         CompositeNodeBuilder<ImmutableCompositeNode> anxmlCompositeBuilder = ImmutableCompositeNode.builder().setQName(
                 QName.create(MODULE_BASE, "anxml-composite"));
         anxmlCompositeBuilder.add(NodeFactory.createImmutableSimpleNode(QName.create(MODULE_BASE, "anxml-cont"), null,
                 null));
-        contBuilder.add(anxmlCompositeBuilder.toInstance());
+        contBuilder.add(anxmlCompositeBuilder.build());
 
         // anxml-simple
         contBuilder.add(NodeFactory.createImmutableSimpleNode(QName.create(MODULE_BASE, "anxml-simple"), null,43));
 
-        return contBuilder.toInstance();
+        return contBuilder.build();
     }
 
     /**
@@ -265,7 +265,7 @@ public class TestUtils {
                                 .setQName(QName.create("simple:container:yang", "2013-11-12", "anxml-composite"))
                                 .add(NodeFactory.createImmutableSimpleNode(
                                         QName.create("simple:container:yang", "2013-11-12", "anxml-cont"), null, null))
-                                .toInstance()).build());
+                                .build()).build());
 
         containerBuilder
                 .withChild(Builders
index fc37a26923ccc971e7053e31a1aa500ac9fc91b8..a38837d1c8f798558c35562cd15face65a1646cf 100644 (file)
@@ -278,6 +278,11 @@ public final class ImmutableCompositeNode extends AbstractNodeTO<List<Node<?>>>
         }
 
         @Override
+        public ImmutableCompositeNode build() {
+            return ImmutableCompositeNode.create(this.getQName(), this.getAttributes(), this.getChildNodes());
+        }
+
+        @Deprecated
         public ImmutableCompositeNode toInstance() {
             return ImmutableCompositeNode.create(this.getQName(), this.getAttributes(), this.getChildNodes());
         }
index b3de8994df623f9dd2e125a824505cf7c45db963..59586ba2d48d14aec65419e3c2e804f18ce45d75 100644 (file)
@@ -9,16 +9,23 @@ package org.opendaylight.yangtools.yang.data.impl.util;
 
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.Node;
 
 public interface NodeBuilder<P extends Node<?>, T extends NodeBuilder<P, T>> extends Builder<P> {
 
     T setQName(QName name);
-    
+
     QName getQName();
 
     T setAttribute(QName attrName, String attrValue);
 
     T setAttribute(String attrName, String attrValue);
 
+    /*
+     * @deprecated use #build()
+     */
+    @Deprecated
+    P toInstance();
+
 }
index 11fcb347d43a3398703bb3252bd18b4845e9dc23..8582b6ec38e25cb57cf89cd7b9d3224ad6574242 100644 (file)
@@ -68,7 +68,7 @@ public final class ConstraintsBuilderImpl implements ConstraintsBuilder {
      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IConstraintsBuilder#build()
      */
     @Override
-    public ConstraintDefinition toInstance() {
+    public ConstraintDefinition build() {
         if (instance != null) {
             return instance;
         }
@@ -322,4 +322,13 @@ public final class ConstraintsBuilderImpl implements ConstraintsBuilder {
         }
     }
 
+    /*
+     * @deprecated Use #build() instead.
+     */
+    @Override
+    @Deprecated
+    public ConstraintDefinition toInstance() {
+        return build();
+    }
+
 }