Add ImmutableNode.newXYXBuilder() methods 70/109570/6
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 1 Jan 2024 14:42:39 +0000 (15:42 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 3 Jan 2024 14:29:58 +0000 (15:29 +0100)
Add convenience methods forwarding to BuilderFactory and migrate most
users of deprecated constructs.

JIRA: YANGTOOLS-1259
Change-Id: I78451bca62503f87422b285c48b5167b6819806a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
68 files changed:
benchmarks/src/main/java/org/opendaylight/yangtools/yang/data/impl/tree/InMemoryDataTreeBenchmark.java
codec/yang-data-codec-binfmt/pom.xml
codec/yang-data-codec-binfmt/src/test/java/org/opendaylight/yangtools/yang/data/codec/binfmt/MapEntrySerializationTest.java
codec/yang-data-codec-binfmt/src/test/java/org/opendaylight/yangtools/yang/data/codec/binfmt/NormalizedNodeStreamReaderWriterTest.java
codec/yang-data-codec-binfmt/src/test/java/org/opendaylight/yangtools/yang/data/codec/binfmt/TestModel.java
codec/yang-data-codec-gson/src/main/java/module-info.java
codec/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONCodecFactory.java
codec/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AbstractComplexJsonTest.java
codec/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug5446Test.java
codec/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug7246Test.java
codec/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/InputStreamNormalizerTest.java
codec/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/JsonStreamToNormalizedNodeTest.java
codec/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java
codec/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/YT1472Test.java
codec/yang-data-codec-xml/src/main/java/module-info.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/AnydataNormalizeContentTest.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/AnydataSerializeTest.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug5446Test.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodeXmlTranslationTest.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodesToXmlTest.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemaOrderedNormalizedNodeWriterTest.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemalessXMLStreamNormalizedNodeStreamWriterTest.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YT1107Test.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YT1108Test.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YT1472Test.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YT1543Test.java
data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/ReusableImmutableNormalizedNodeStreamWriter.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/ImmutableNormalizedNodeStreamWriterTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedNodeUtilsTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/OrderingEqualityTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/nodes/YT1417Test.java
data/yang-data-spi/src/main/java/org/opendaylight/yangtools/yang/data/spi/node/ImmutableNodes.java
data/yang-data-spi/src/test/java/org/opendaylight/yangtools/yang/data/spi/node/impl/BuilderTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/AbstractPrettyTreeTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug2690Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug3674Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug4295Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug4454Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug5830Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug5968MergeTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug5968Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug8291Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/CaseAugmentTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/CaseExclusionTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ConcurrentTreeModificationTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ConfigStatementValidationTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/DataTreeCandidatesTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ErrorReportingTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ListConstraintsValidation.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/MandatoryLeafTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ModificationMetadataTreeTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/OrderedListTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/StoreTreeNodesTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/StructuralApplyModificationTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/UniqueConstraintTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/YT1104Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/YT1276Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/YT776Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/leafref/Bug8713Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/leafref/DataTreeCandidateValidatorTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/leafref/DataTreeCandidateValidatorTest2.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/leafref/DataTreeCandidateValidatorTest3.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/leafref/YT821Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/leafref/YT891Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/leafref/YT892Test.java

index 4097379a54779747765a8ed7966116df07a2d9fb..f8022ac34d98d46e56b02920134326a1225fa661 100644 (file)
@@ -10,14 +10,12 @@ package org.opendaylight.yangtools.yang.data.impl.tree;
 import com.google.common.collect.Streams;
 import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.CursorAwareDataTreeModification;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -63,19 +61,22 @@ public class InMemoryDataTreeBenchmark {
     private static final NodeIdentifierWithPredicates[] OUTER_LIST_IDS = Streams.mapWithIndex(
         IntStream.range(0, OUTER_LIST_100K),
         (i, index) -> NodeIdentifierWithPredicates.of(BenchmarkModel.OUTER_LIST_QNAME, BenchmarkModel.ID_QNAME, i))
-            .collect(Collectors.toList()).toArray(new NodeIdentifierWithPredicates[0]);
+            .toArray(NodeIdentifierWithPredicates[]::new);
 
     private static final YangInstanceIdentifier[] OUTER_LIST_PATHS = Arrays.stream(OUTER_LIST_IDS)
             .map(id -> BenchmarkModel.OUTER_LIST_PATH.node(id).toOptimized())
-            .collect(Collectors.toList()).toArray(new YangInstanceIdentifier[0]);
+            .toArray(YangInstanceIdentifier[]::new);
 
-    private static final MapNode EMPTY_OUTER_LIST = ImmutableNodes.mapNodeBuilder(BenchmarkModel.OUTER_LIST).build();
+    private static final MapNode EMPTY_OUTER_LIST = ImmutableNodes.newSystemMapBuilder()
+        .withNodeIdentifier(BenchmarkModel.OUTER_LIST)
+        .build();
     private static final MapNode ONE_ITEM_INNER_LIST = initInnerListItems(1);
     private static final MapNode TWO_ITEM_INNER_LIST = initInnerListItems(2);
     private static final MapNode TEN_ITEM_INNER_LIST = initInnerListItems(10);
 
     private static MapNode initInnerListItems(final int count) {
-        final var mapEntryBuilder = ImmutableNodes.mapNodeBuilder(BenchmarkModel.INNER_LIST);
+        final var mapEntryBuilder = ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(BenchmarkModel.INNER_LIST);
 
         for (int i = 0; i < count; ++i) {
             mapEntryBuilder
@@ -95,7 +96,7 @@ public class InMemoryDataTreeBenchmark {
     private static MapEntryNode[] initOuterListItems(final int outerListItemsCount, final MapNode innerList) {
         return Arrays.stream(OUTER_LIST_IDS)
             .limit(outerListItemsCount)
-            .map(id -> ImmutableNodes.mapEntryBuilder().withNodeIdentifier(id).withChild(innerList).build())
+            .map(id -> ImmutableNodes.newMapEntryBuilder().withNodeIdentifier(id).withChild(innerList).build())
             .toArray(MapEntryNode[]::new);
     }
 
@@ -116,7 +117,7 @@ public class InMemoryDataTreeBenchmark {
             BenchmarkModel.createTestContext());
 
         final DataTreeModification modification = begin();
-        modification.write(BenchmarkModel.TEST_PATH, Builders.containerBuilder()
+        modification.write(BenchmarkModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(BenchmarkModel.TEST)
             .withChild(EMPTY_OUTER_LIST)
             .build());
index 69ba6378997e29891d589221a980ea1787b39618..1eea655595fc3efe5f84d84e0dd881727295d2b1 100644 (file)
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-data-impl</artifactId>
+            <artifactId>yang-data-spi</artifactId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-model-api</artifactId>
+            <artifactId>yang-data-impl</artifactId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-data-tree-spi</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-model-api</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
index 01bf2f65901c3a0a53e81e89f4158e019aa91ac9..4846b7a200e768d1d53be7333c5de525fe400a7a 100644 (file)
@@ -15,7 +15,6 @@ import org.junit.jupiter.params.provider.MethodSource;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
 class MapEntrySerializationTest extends AbstractSerializationTest {
@@ -60,7 +59,7 @@ class MapEntrySerializationTest extends AbstractSerializationTest {
     }
 
     private static MapEntryNode createEntry(final int size) {
-        final var builder = Builders.mapEntryBuilder();
+        final var builder = ImmutableNodes.newMapEntryBuilder();
         final var predicates = Maps.<QName, Object>newHashMapWithExpectedSize(size);
         for (var qname : generateQNames(size)) {
             builder.withChild(ImmutableNodes.leafNode(qname, "a"));
index 75be56533bff27badad909a253d78e5d5eeb9899..ae64f2d49140cf3fbadcaf2e60046b7df08d4a95 100644 (file)
@@ -34,11 +34,9 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 import org.xml.sax.InputSource;
@@ -56,11 +54,11 @@ class NormalizedNodeStreamReaderWriterTest {
         final var toaster = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","toaster");
         final var darknessFactor = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","darknessFactor");
         final var description = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","description");
-        final var toasterNode = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(toaster))
+        final var toasterNode = ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(toaster))
                 .withChild(ImmutableNodes.leafNode(darknessFactor, "1000"))
                 .withChild(ImmutableNodes.leafNode(description, largeString(20))).build();
 
-        final var toasterContainer = Builders.containerBuilder()
+        final var toasterContainer = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME)).withChild(toasterNode).build();
         nnout.writeNormalizedNode(toasterContainer);
 
@@ -82,20 +80,14 @@ class NormalizedNodeStreamReaderWriterTest {
         final byte[] bytes2 = {};
 
         return TestModel.createBaseTestContainerBuilder()
-            .withChild(Builders.leafSetBuilder()
+            .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME))
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1))
-                    .withValue(bytes1)
-                    .build())
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2))
-                    .withValue(bytes2)
-                    .build())
+                .withChild(ImmutableNodes.leafSetEntry(TestModel.BINARY_LEAF_LIST_QNAME, bytes1))
+                .withChild(ImmutableNodes.leafSetEntry(TestModel.BINARY_LEAF_LIST_QNAME, bytes2))
                 .build())
             .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4}))
             .withChild(ImmutableNodes.leafNode(TestModel.EMPTY_QNAME, Empty.value()))
-            .withChild(Builders.orderedMapBuilder()
+            .withChild(ImmutableNodes.newUserMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.ORDERED_LIST_QNAME))
                 .withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME, TestModel.ID_QNAME, 11))
                 .build())
@@ -185,9 +177,9 @@ class NormalizedNodeStreamReaderWriterTest {
 
         assertEquals("http://www.w3.org/TR/html4/", xmlNode.getNamespaceURI());
 
-        final var anyXmlContainer = Builders.containerBuilder()
+        final var anyXmlContainer = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.anyXmlBuilder()
+            .withChild(ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
                 .withNodeIdentifier(new NodeIdentifier(TestModel.ANY_XML_QNAME))
                 .withValue(new DOMSource(xmlNode))
                 .build())
@@ -270,8 +262,9 @@ class NormalizedNodeStreamReaderWriterTest {
     @ParameterizedTest
     @MethodSource
     void testHugeEntries(final NormalizedNodeStreamVersion version, final int size) throws Exception {
-        final var mapBuilder = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME));
-        final var entryBuilder = Builders.mapEntryBuilder()
+        final var mapBuilder = ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME));
+        final var entryBuilder = ImmutableNodes.newMapEntryBuilder()
             .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, (byte) 42));
 
         for (int i = 0; i < 100_000; ++i) {
index 64c83b1a207d72f3cefa7a021995ab047d4b5094..ef0900095796c9b4c161fc397409ef0b4cefdf3c 100644 (file)
@@ -7,11 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.data.codec.binfmt;
 
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
-
 import com.google.common.collect.ImmutableSet;
 import org.opendaylight.yangtools.yang.common.Decimal64;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -23,7 +18,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithV
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
 public final class TestModel {
     static final QName TEST_QNAME = QName.create(
@@ -79,10 +74,13 @@ public final class TestModel {
     static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME, "child-number");
     static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, "child-name");
 
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(OUTER_LIST_QNAME, ID_QNAME, TWO_ID)
-        .withChild(mapNodeBuilder(INNER_LIST_QNAME)
-            .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME))
-            .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME))
+    private static final MapEntryNode BAR_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(OUTER_LIST_QNAME, ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.leafNode(ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(INNER_LIST_QNAME))
+            .withChild(ImmutableNodes.mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME))
+            .withChild(ImmutableNodes.mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME))
             .build())
         .build();
 
@@ -92,81 +90,68 @@ public final class TestModel {
 
     public static DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
         // Create the document
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
             // Create a bits leaf
-            .withChild(leafNode(QName.create(TEST_QNAME, "my-bits"), ImmutableSet.of("foo", "bar")))
-            .withChild(leafNode(DESC_QNAME, DESC))
-            .withChild(leafNode(BOOLEAN_LEAF_QNAME, ENABLED))
-            .withChild(leafNode(SHORT_LEAF_QNAME, SHORT_ID))
-            .withChild(leafNode(BYTE_LEAF_QNAME, BYTE_ID))
-            .withChild(leafNode(TestModel.BIGINTEGER_LEAF_QNAME, Uint64.valueOf(100)))
-            .withChild(leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, Decimal64.valueOf("1.2")))
-            .withChild(leafNode(SOME_REF_QNAME,
+            .withChild(ImmutableNodes.leafNode(QName.create(TEST_QNAME, "my-bits"), ImmutableSet.of("foo", "bar")))
+            .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
+            .withChild(ImmutableNodes.leafNode(BOOLEAN_LEAF_QNAME, ENABLED))
+            .withChild(ImmutableNodes.leafNode(SHORT_LEAF_QNAME, SHORT_ID))
+            .withChild(ImmutableNodes.leafNode(BYTE_LEAF_QNAME, BYTE_ID))
+            .withChild(ImmutableNodes.leafNode(TestModel.BIGINTEGER_LEAF_QNAME, Uint64.valueOf(100)))
+            .withChild(ImmutableNodes.leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, Decimal64.valueOf("1.2")))
+            .withChild(ImmutableNodes.leafNode(SOME_REF_QNAME,
                 // Create YangInstanceIdentifier with all path arg types.
                 YangInstanceIdentifier.of(new NodeIdentifier(QName.create(TEST_QNAME, "qname")),
                     NodeIdentifierWithPredicates.of(QName.create(TEST_QNAME, "list-entry"),
                         QName.create(TEST_QNAME, "key"), 10),
                     new NodeWithValue<>(QName.create(TEST_QNAME, "leaf-list-entry"), "foo"))))
-            .withChild(leafNode(MYIDENTITY_QNAME, DESC_QNAME))
-            .withChild(Builders.unkeyedListBuilder()
+            .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
+            .withChild(ImmutableNodes.newUnkeyedListBuilder()
                 .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
                 // Create unkeyed list entry
-                .withChild(Builders.unkeyedListEntryBuilder()
+                .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
                     .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
-                    .withChild(leafNode(NAME_QNAME, "unkeyed-entry-name"))
+                    .withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed-entry-name"))
                     .build())
                 .build())
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TWO_THREE_QNAME))
-                .withChild(leafNode(TWO_QNAME, "two"))
+                .withChild(ImmutableNodes.leafNode(TWO_QNAME, "two"))
                 .build())
-            .withChild(Builders.orderedMapBuilder()
+            .withChild(ImmutableNodes.newUserMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ORDERED_LIST_QNAME))
-                .withChild(mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "1").build())
-                .withChild(mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "2").build())
+                .withChild(ImmutableNodes.mapEntry(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "1"))
+                .withChild(ImmutableNodes.mapEntry(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "2"))
                 .build())
             // Create a list of shoes
-            .withChild(Builders.leafSetBuilder()
+            .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                 .withNodeIdentifier(new NodeIdentifier(SHOE_QNAME))
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(SHOE_QNAME, "nike"))
-                    .withValue("nike")
-                    .build())
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(SHOE_QNAME, "puma"))
-                    .withValue("puma")
-                    .build())
+                .withChild(ImmutableNodes.leafSetEntry(SHOE_QNAME, "nike"))
+                .withChild(ImmutableNodes.leafSetEntry(SHOE_QNAME, "puma"))
                 .build())
             // Create a leaf list with numbers
-            .withChild(Builders.leafSetBuilder()
+            .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                 .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "number")))
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5))
-                    .withValue(5)
-                    .build())
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15))
-                    .withValue(15)
-                    .build())
+                .withChild(ImmutableNodes.leafSetEntry(QName.create(TEST_QNAME, "number"), 5))
+                .withChild(ImmutableNodes.leafSetEntry(QName.create(TEST_QNAME, "number"), 15))
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(SWITCH_FEATURES_QNAME))
                 // Test a leaf-list where each entry contains an identity
-                .withChild(Builders.leafSetBuilder()
+                .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                     .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "capability")))
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "capability"), DESC_QNAME))
-                        .withValue(DESC_QNAME)
-                        .build())
+                    .withChild(ImmutableNodes.leafSetEntry(QName.create(TEST_QNAME, "capability"), DESC_QNAME))
                     .build())
                 .build())
-            .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(AUGMENTED_LIST_QNAME))
                 // Create augmentations
                 .withChild(createAugmentedListEntry(1, "First Test"))
                 .build())
-            .withChild(mapNodeBuilder(OUTER_LIST_QNAME)
-                .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(OUTER_LIST_QNAME))
+                .withChild(ImmutableNodes.mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
                 .withChild(BAR_NODE)
                 .build());
     }
@@ -176,12 +161,12 @@ public final class TestModel {
     }
 
     private static MapEntryNode createAugmentedListEntry(final int id, final String name) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(AUGMENTED_LIST_QNAME, ID_QNAME, id))
-            .withChild(leafNode(ID_QNAME, id))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.leafNode(ID_QNAME, id))
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(AUG_CONT_QNAME))
-                .withChild(leafNode(AUG_NAME_QNAME, name))
+                .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name))
                 .build())
             .build();
     }
index 9fa22b613bafa537ebdfd31abada0780dec69856..a61395772fdf9c7b5c1020c53d31231e1227ab5f 100644 (file)
@@ -16,6 +16,7 @@ module org.opendaylight.yangtools.yang.data.codec.gson {
     requires org.opendaylight.yangtools.util;
     requires org.opendaylight.yangtools.yang.common;
     requires org.opendaylight.yangtools.yang.data.impl;
+    requires org.opendaylight.yangtools.yang.data.spi;
     requires org.opendaylight.yangtools.yang.data.util;
     requires org.opendaylight.yangtools.yang.model.api;
     requires org.opendaylight.yangtools.yang.model.util;
index 756e863e9b73af57fe16b40410eab4684f977615..0b45f1db2ea0832bfbdfaec73589c1dccbdd748d 100644 (file)
@@ -26,7 +26,6 @@ import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode.BuilderFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizationException;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizationResult;
 import org.opendaylight.yangtools.yang.data.impl.codec.AbstractIntegerStringCodec;
@@ -113,8 +112,6 @@ public abstract sealed class JSONCodecFactory extends AbstractInputStreamNormali
         }
     }
 
-    private static final BuilderFactory BUILDER_FACTORY = ImmutableNodes.builderFactory();
-
     private final @NonNull JSONInstanceIdentifierCodec iidCodec;
 
     @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
@@ -283,7 +280,7 @@ public abstract sealed class JSONCodecFactory extends AbstractInputStreamNormali
                 throw NormalizationException.ofMessage("Expected name '" + expected + "', got '" + name + "'");
             }
 
-            final var builder = BUILDER_FACTORY.newContainerBuilder().withNodeIdentifier(containerName);
+            final var builder = ImmutableNodes.newContainerBuilder().withNodeIdentifier(containerName);
 
             if (reader.peek() == JsonToken.BEGIN_OBJECT) {
                 try (var writer = ImmutableNormalizedNodeStreamWriter.from(builder)) {
index e9d1f2dc22b35f5eda625820a0b2afa64db8474c..16889281e9f684969b43442ad5e757b5b6a54105 100644 (file)
@@ -23,7 +23,7 @@ abstract class AbstractComplexJsonTest {
 
     private static final QName EMPTY_LEAF = QName.create(CONT_1, "empty");
 
-    static final ContainerNode CONT1_WITH_EMPTYLEAF = ImmutableNodes.builderFactory().newContainerBuilder()
+    static final ContainerNode CONT1_WITH_EMPTYLEAF = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(CONT_1_NODEID)
             .addChild(ImmutableNodes.leafNode(EMPTY_LEAF, Empty.value()))
             .build();
index aa371f19b3fd53336107986962cee768dd38f02c..cf699cacf8982ec4b6953a341528cd9d6561c82f 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -68,7 +67,7 @@ class Bug5446Test {
               }
             }""");
 
-        final var jsonOutput = normalizedNodeToJsonStreamTransformation(Builders.containerBuilder()
+        final var jsonOutput = normalizedNodeToJsonStreamTransformation(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
             .withChild(ImmutableNodes.leafNode(IP_ADDRESS_QNAME, Base64.getDecoder().decode("fwAAAQ==")))
             .build());
index a408503ac32cb56942b7f8fe88146cb9195cae73..21507e79442ff1ca9c2f730e9b5e0bfca4237112 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
@@ -66,7 +65,7 @@ class Bug7246Test {
                 }
               }
             }""");
-        final var inputStructure = Builders.containerBuilder()
+        final var inputStructure = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(qN("my-name")))
             .withChild(ImmutableNodes.leafNode(new NodeIdentifier(qN("my-name")), "my-value"))
             .build();
index 6819db91209d093130a62a436f60a0b47db03b1e..718685011031941fbcddf7cbc19e802111d375de 100644 (file)
@@ -29,7 +29,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangNetconfError;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.InputStreamNormalizer;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizationException;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
@@ -108,13 +107,13 @@ class InputStreamNormalizerTest {
 
     @Test
     void parseDatastore() throws Exception {
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(DATA_NID)
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(FOO))
                 .withChild(ImmutableNodes.leafNode(STR, "str"))
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(BAR))
                 .withChild(ImmutableNodes.leafNode(UINT, Uint32.TWO))
                 .build())
@@ -134,7 +133,7 @@ class InputStreamNormalizerTest {
 
     @Test
     void parseData() throws Exception {
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafNode(STR, "str"))
             .build(),
@@ -197,7 +196,7 @@ class InputStreamNormalizerTest {
             }"""));
 
         assertEquals(List.of(), prefixAndNode.prefix());
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafNode(STR, "str"))
             .build(), prefixAndNode.result().data());
@@ -227,7 +226,7 @@ class InputStreamNormalizerTest {
               ]
             }"""));
         assertEquals(List.of(new NodeIdentifier(BAZ)), prefixAndNode.prefix());
-        assertEquals(Builders.mapEntryBuilder()
+        assertEquals(ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(BAZ, Map.of(ONE, Boolean.TRUE, TWO, "two")))
             .withChild(ImmutableNodes.leafNode(ONE, Boolean.TRUE))
             .withChild(ImmutableNodes.leafNode(TWO, "two"))
@@ -268,7 +267,7 @@ class InputStreamNormalizerTest {
               }
             }"""));
         assertEquals(List.of(new NodeIdentifier(BAZ)), prefixAndNode.prefix());
-        assertEquals(Builders.mapEntryBuilder()
+        assertEquals(ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(BAZ, Map.of(ONE, Boolean.TRUE, TWO, "two")))
             .withChild(ImmutableNodes.leafNode(ONE, Boolean.TRUE))
             .withChild(ImmutableNodes.leafNode(TWO, "two"))
@@ -312,7 +311,7 @@ class InputStreamNormalizerTest {
         final var stack = SchemaInferenceStack.of(MODEL_CONTEXT);
         stack.enterSchemaTree(THUD);
 
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(QName.create("foo", "input")))
             .withChild(ImmutableNodes.leafNode(UINT, Uint32.TWO))
             .build(),
@@ -342,7 +341,7 @@ class InputStreamNormalizerTest {
         stack.enterSchemaTree(BAZ);
         stack.enterSchemaTree(QUX);
 
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(QName.create("foo", "input")))
             .withChild(ImmutableNodes.leafNode(STR, "str"))
             .build(),
@@ -369,7 +368,7 @@ class InputStreamNormalizerTest {
         final var stack = SchemaInferenceStack.of(MODEL_CONTEXT);
         stack.enterSchemaTree(THUD);
 
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(QName.create("foo", "output")))
             .build(),
             PARSER.parseOutput(stack.toInference(), stream("""
@@ -397,7 +396,7 @@ class InputStreamNormalizerTest {
         stack.enterSchemaTree(BAZ);
         stack.enterSchemaTree(QUX);
 
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(QName.create("foo", "output")))
             .build(),
             PARSER.parseOutput(stack.toInference(), stream("""
index 47f841e8c3453dbd3ca777500f5ae493618a6897..fbb6d9834f3badf7e0d5e3641a6dd11afecefffb 100644 (file)
@@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -213,13 +212,13 @@ class JsonStreamToNormalizedNodeTest extends AbstractComplexJsonTest {
         final var containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container");
         final var leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf");
 
-        final var cont1Normalized = Builders.containerBuilder()
+        final var cont1Normalized = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(CONT_1))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(new NodeIdentifier(augmentChoice1QName))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(augmentChoice2QName))
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(new NodeIdentifier(containerQName))
                         .withChild(ImmutableNodes.leafNode(leafQName, "leaf-value"))
                         .build())
index 6114e90a8bb6d4ad2b75dcf9760c93dd6b1c5349..de59ef9313a8649d78d3bf71145487dbfb9fb206 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.yang.data.codec.gson;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
-import java.util.Arrays;
+import java.util.List;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -26,7 +26,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
 final class TestingNormalizedNodeStructuresCreator {
     private static final QNameModule COMPLEX_JSON =
@@ -39,116 +39,87 @@ final class TestingNormalizedNodeStructuresCreator {
     }
 
     static ContainerNode cont1Node(final DataContainerChild... children) {
-        return Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "cont1")))
-                .withValue(Arrays.asList(children))
-                .build();
+        return ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "cont1")))
+            .withValue(List.of(children))
+            .build();
     }
 
     static ContainerNode cont2Node() {
-        return Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "cont2")))
-                .build();
+        return ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "cont2")))
+            .build();
     }
 
     private static UnkeyedListNode lst12Node() {
-        return Builders.unkeyedListBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lst12")))
-                .withChild(lst12Entry1Node())
-                .build();
+        return ImmutableNodes.newUnkeyedListBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lst12")))
+            .withChild(lst12Entry1Node())
+            .build();
     }
 
     private static UnkeyedListEntryNode lst12Entry1Node() {
-        return Builders.unkeyedListEntryBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lst12")))
-                .withChild(Builders.leafBuilder()
-                    .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf121")))
-                    .withValue("lf121 value").build())
-                .build();
+        return ImmutableNodes.newUnkeyedListEntryBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lst12")))
+            .withChild(ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf121"), "lf121 value"))
+            .build();
     }
 
     private static ChoiceNode choc12Node() {
-        return Builders.choiceBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "choc12")))
-                .withChild(lf17Node())
-                .build();
+        return ImmutableNodes.newChoiceBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "choc12")))
+            .withChild(lf17Node())
+            .build();
     }
 
-    protected static LeafNode<Object> lf17Node() {
-        return Builders.leafBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf17")))
-                .withValue("lf17 value").build();
+    protected static LeafNode<?> lf17Node() {
+        return ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf17"), "lf17 value");
     }
 
-    private static LeafNode<Object> lf15_12NodeExternal() {
-        return Builders.leafBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON_AUG, "lf15_12")))
-                .withValue("lf15_12 value from augmentation")
-                .build();
+    private static LeafNode<?> lf15_12NodeExternal() {
+        return ImmutableNodes.leafNode(QName.create(COMPLEX_JSON_AUG, "lf15_12"), "lf15_12 value from augmentation");
     }
 
-    private static LeafNode<Object> lf15_11NodeExternal() {
-        return Builders.leafBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON_AUG, "lf15_11")))
-                .withValue("lf15_11 value from augmentation")
-                .build();
+    private static LeafNode<?> lf15_11NodeExternal() {
+        return ImmutableNodes.leafNode(QName.create(COMPLEX_JSON_AUG, "lf15_11"), "lf15_11 value from augmentation");
     }
 
     private static ChoiceNode choc11Node(final DataContainerChild... children) {
-        return Builders.choiceBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "choc11")))
-                .withValue(Arrays.asList(children))
-                // choc11Builder.addChild(lf13Node());
-                // choc11Builder.addChild(augmentChoc11_c11A_lf1511AndLf1512Children());
-                // choc11Builder.addChild(augmentChoc11_c11_lf1521Children());
-                .build();
+        return ImmutableNodes.newChoiceBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "choc11")))
+            .withValue(List.of(children))
+            .build();
     }
 
-    private static LeafNode<Object> lf13Node() {
-        return Builders.leafBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf13")))
-                .withValue("lf13 value").build();
+    private static LeafNode<?> lf13Node() {
+        return ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf13"), "lf13 value");
     }
 
-    private static LeafNode<Object> lf15_21Node() {
-        return Builders.leafBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf15_21")))
-                .withValue("lf15_21 value").build();
+    private static LeafNode<?> lf15_21Node() {
+        return ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf15_21"), "lf15_21 value");
     }
 
-    private static LeafNode<Object> lf15_12Node() {
-        return Builders.leafBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf15_12")))
-                .withValue(QName.create(COMPLEX_JSON, "ident")).build();
+    private static LeafNode<?> lf15_12Node() {
+        return ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf15_12"), QName.create(COMPLEX_JSON, "ident"));
     }
 
     private static LeafNode<Object> lf15_11Node() {
-        return Builders.leafBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf15_11")))
-                .withValue(ImmutableSet.of("one", "two")).build();
+        return ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf15_11"), ImmutableSet.of("one", "two"));
     }
 
     private static SystemMapNode childLst11() {
-        return Builders.mapBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lst11")))
-                .withChild(Builders.mapEntryBuilder().withNodeIdentifier(
-                    NodeIdentifierWithPredicates.of(QName.create(COMPLEX_JSON, "lst11"), ImmutableMap.of(
-                        QName.create(COMPLEX_JSON, "key111"), "key111 value",
-                        QName.create(COMPLEX_JSON, "lf111"), "lf111 value")))
-                    .withChild(Builders.leafBuilder()
-                        .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "key111")))
-                        .withValue("key111 value").build())
-                    .withChild(Builders.leafBuilder()
-                        .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf112")))
-                        .withValue(lf112Value()).build())
-                    .withChild(Builders.leafBuilder()
-                        .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf113")))
-                        .withValue("lf113 value").build())
-                    .withChild(Builders.leafBuilder()
-                        .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf111")))
-                        .withValue("lf111 value").build())
-                    .build())
-                .build();
+        return ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lst11")))
+            .withChild(ImmutableNodes.newMapEntryBuilder().withNodeIdentifier(
+                NodeIdentifierWithPredicates.of(QName.create(COMPLEX_JSON, "lst11"), ImmutableMap.of(
+                    QName.create(COMPLEX_JSON, "key111"), "key111 value",
+                    QName.create(COMPLEX_JSON, "lf111"), "lf111 value")))
+                .withChild(ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "key111"), "key111 value"))
+                .withChild(ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf112"), lf112Value()))
+                .withChild(ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf113"), "lf113 value"))
+                .withChild(ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf111"), "lf111 value"))
+                .build())
+            .build();
     }
 
     private static Object lf112Value() {
@@ -159,35 +130,25 @@ final class TestingNormalizedNodeStructuresCreator {
     }
 
     private static SystemLeafSetNode<?> childLflst11() {
-        return Builders.leafSetBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lflst11")))
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(QName.create(COMPLEX_JSON, "lflst11"), "lflst11 value1"))
-                    .withValue("lflst11 value1").build())
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(QName.create(COMPLEX_JSON, "lflst11"), "lflst11 value2"))
-                    .withValue("lflst11 value2").build())
-                .build();
+        return ImmutableNodes.newSystemLeafSetBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lflst11")))
+            .withChild(ImmutableNodes.leafSetEntry(QName.create(COMPLEX_JSON, "lflst11"), "lflst11 value1"))
+            .withChild(ImmutableNodes.leafSetEntry(QName.create(COMPLEX_JSON, "lflst11"), "lflst11 value2"))
+            .build();
     }
 
     private static SystemLeafSetNode<?> childLflst11Multiline() {
-        return Builders.leafSetBuilder()
-                .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lflst11")))
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(QName.create(COMPLEX_JSON, "lflst11"),
-                            "lflst11 value1\nanother line 1"))
-                    .withValue("lflst11 value1\nanother line 1").build())
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(QName.create(COMPLEX_JSON, "lflst11"),
-                            "lflst11 value2\r\nanother line 2"))
-                    .withValue("lflst11 value2\r\nanother line 2").build())
-                .build();
+        return ImmutableNodes.newSystemLeafSetBuilder()
+            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lflst11")))
+            .withChild(ImmutableNodes.leafSetEntry(QName.create(COMPLEX_JSON, "lflst11"),
+                "lflst11 value1\nanother line 1"))
+            .withChild(ImmutableNodes.leafSetEntry(QName.create(COMPLEX_JSON, "lflst11"),
+                "lflst11 value2\r\nanother line 2"))
+            .build();
     }
 
     public static ContainerNode leafNodeInContainer() {
-        return cont1Node(Builders.leafBuilder()
-            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf11")))
-            .withValue(453).build());
+        return cont1Node(ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf11"), 453));
     }
 
     public static ContainerNode leafListNodeInContainer() {
@@ -203,10 +164,7 @@ final class TestingNormalizedNodeStructuresCreator {
     }
 
     public static ContainerNode leafNodeViaAugmentationInContainer() {
-        return cont1Node(Builders.leafBuilder()
-            .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "lf12_1")))
-            .withValue("lf12 value")
-            .build());
+        return cont1Node(ImmutableNodes.leafNode(QName.create(COMPLEX_JSON, "lf12_1"), "lf12 value"));
     }
 
     public static ContainerNode choiceNodeInContainer() {
@@ -221,8 +179,8 @@ final class TestingNormalizedNodeStructuresCreator {
     }
 
     public static ContainerNode caseNodeExternalAugmentationInChoiceInContainer() {
-        return cont1Node(choc11Node(lf13Node(), lf15_11Node(), lf15_12Node(),
-            lf15_11NodeExternal(), lf15_12NodeExternal()));
+        return cont1Node(choc11Node(lf13Node(), lf15_11Node(), lf15_12Node(), lf15_11NodeExternal(),
+            lf15_12NodeExternal()));
     }
 
     public static ContainerNode choiceNodeAugmentationInContainer() {
@@ -238,7 +196,7 @@ final class TestingNormalizedNodeStructuresCreator {
     }
 
     public static ContainerNode emptyContainerInContainer() {
-        return cont1Node(Builders.containerBuilder()
+        return cont1Node(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "cont11")))
             .build());
     }
index 7778972a273e5eb22e301b120ec58845d05f10be..12c694b8f07821f1af11d53e039318eca041f661 100644 (file)
@@ -19,7 +19,6 @@ import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.common.YangDataName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -66,11 +65,11 @@ class YT1472Test {
                 ]
               }
             }""")));
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(NodeIdentifier.create(QName.create(RESTCONF_MODULE, "errors")))
-            .withChild(Builders.unkeyedListBuilder()
+            .withChild(ImmutableNodes.newUnkeyedListBuilder()
                 .withNodeIdentifier(ERROR_NID)
-                .withChild(Builders.unkeyedListEntryBuilder()
+                .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
                     .withNodeIdentifier(ERROR_NID)
                     .withChild(ImmutableNodes.leafNode(QName.create(RESTCONF_MODULE, "error-type"), "protocol"))
                     .withChild(ImmutableNodes.leafNode(QName.create(RESTCONF_MODULE, "error-tag"), "lock-denied"))
index b826fdf7a5dd85cdacd08d22cde7079b3329ac95..6a0b7fcad53cf6faaac4043d33cf1d66439c5fba 100644 (file)
@@ -24,4 +24,5 @@ module org.opendaylight.yangtools.yang.data.codec.xml {
 
     // Annotations
     requires static org.eclipse.jdt.annotation;
+    requires org.opendaylight.yangtools.yang.data.spi;
 }
index 68a17ad93abf29bcb91e31c62c92e9ef518308da..d90bef82f64db0b9bcf31d966290f7674992d57b 100644 (file)
@@ -19,15 +19,13 @@ import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.AnydataNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedAnydata;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
 
 class AnydataNormalizeContentTest extends AbstractAnydataTest {
@@ -69,21 +67,21 @@ class AnydataNormalizeContentTest extends AbstractAnydataTest {
             Arguments.of("container (root level)",
                 ANYDATA_XML,
                 Inference.ofDataTreePath(SCHEMA_CONTEXT, CONT_QNAME),
-                Builders.containerBuilder().withNodeIdentifier(CONT_NODEID).withChild(LEAF_NODE).build()),
+                ImmutableNodes.newContainerBuilder().withNodeIdentifier(CONT_NODEID).withChild(LEAF_NODE).build()),
             Arguments.of("container (level 2)",
                 ANYDATA_XML,
                 Inference.ofDataTreePath(SCHEMA_CONTEXT, CONT_QNAME, BAR_QNAME),
-                Builders.containerBuilder().withNodeIdentifier(BAR_NODEID).withChild(LEAF_NODE).build()),
+                ImmutableNodes.newContainerBuilder().withNodeIdentifier(BAR_NODEID).withChild(LEAF_NODE).build()),
             Arguments.of("empty container",
                 ANYDATA_EMPTY_XML,
                 Inference.ofDataTreePath(SCHEMA_CONTEXT, CONT_QNAME, BAR_QNAME),
-                ImmutableNodes.containerNode(BAR_NODEID)),
+                ImmutableNodes.newContainerBuilder().withNodeIdentifier(BAR_NODEID).build()),
             Arguments.of("single list element",
                 ANYDATA_XML,
                 Inference.ofDataTreePath(SCHEMA_CONTEXT, LIST_QNAME),
-                Builders.unkeyedListBuilder()
+                ImmutableNodes.newUnkeyedListBuilder()
                     .withNodeIdentifier(LIST_NODEID)
-                    .withChild(Builders.unkeyedListEntryBuilder()
+                    .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
                         .withNodeIdentifier(LIST_NODEID)
                         .withChild(LEAF_NODE)
                         .build())
@@ -91,21 +89,18 @@ class AnydataNormalizeContentTest extends AbstractAnydataTest {
             Arguments.of("single empty list element",
                 ANYDATA_EMPTY_XML,
                 Inference.ofDataTreePath(SCHEMA_CONTEXT, LIST_QNAME),
-                Builders.unkeyedListBuilder()
+                ImmutableNodes.newUnkeyedListBuilder()
                     .withNodeIdentifier(LIST_NODEID)
-                    .withChild(Builders.unkeyedListEntryBuilder()
+                    .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
                         .withNodeIdentifier(LIST_NODEID)
                         .build())
                     .build()),
             Arguments.of("single empty leaf-list element",
                 ANYDATA_EMPTY_XML,
                 Inference.ofDataTreePath(SCHEMA_CONTEXT, LIST_QNAME, LEAF_LIST_QNAME),
-                Builders.leafSetBuilder()
+                ImmutableNodes.newSystemLeafSetBuilder()
                     .withNodeIdentifier(LEAF_LIST_NODEID)
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(LEAF_LIST_QNAME, ""))
-                        .withValue("")
-                        .build())
+                    .withChild(ImmutableNodes.leafSetEntry(LEAF_LIST_QNAME, ""))
                     .build()),
             Arguments.of("leaf of type empty",
                 ANYDATA_EMPTY_XML,
index 1eb8df9e73c88752ee71a11073a271b8c3e4d0b7..e02de21711ea575f9cc88674f31ad2cdf1aa2d63 100644 (file)
@@ -26,9 +26,9 @@ import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.data.api.schema.AnydataNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedAnydata;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 import org.opendaylight.yangtools.yang.model.spi.DefaultSchemaTreeInference;
 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
@@ -43,7 +43,7 @@ class AnydataSerializeTest extends AbstractAnydataTest {
         final var xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlStreamWriter,
             SCHEMA_CONTEXT);
         final var normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(xmlNormalizedNodeStreamWriter);
-        normalizedNodeWriter.write(Builders.anydataBuilder(DOMSourceAnydata.class)
+        normalizedNodeWriter.write(ImmutableNodes.newAnydataBuilder(DOMSourceAnydata.class)
             .withNodeIdentifier(FOO_NODEID)
             .withValue(toDOMSource("<bar xmlns=\"test-anydata\"/>"))
             .build());
@@ -164,9 +164,9 @@ class AnydataSerializeTest extends AbstractAnydataTest {
         final var xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlStreamWriter,
             SCHEMA_CONTEXT);
         final var normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(xmlNormalizedNodeStreamWriter);
-        normalizedNodeWriter.write(Builders.containerBuilder()
+        normalizedNodeWriter.write(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(CONT_NODEID)
-            .withChild(Builders.anydataBuilder(DOMSourceAnydata.class)
+            .withChild(ImmutableNodes.newAnydataBuilder(DOMSourceAnydata.class)
                 .withNodeIdentifier(CONT_ANY_NODEID)
                 .withValue(toDOMSource("<bar xmlns=\"test-anydata\"/>"))
                 .build())
@@ -188,13 +188,13 @@ class AnydataSerializeTest extends AbstractAnydataTest {
         final var xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlStreamWriter,
             SCHEMA_CONTEXT);
         final var normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(xmlNormalizedNodeStreamWriter);
-        normalizedNodeWriter.write(Builders.containerBuilder()
+        normalizedNodeWriter.write(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(CONT_NODEID)
-            .withChild(Builders.anydataBuilder(NormalizedAnydata.class)
+            .withChild(ImmutableNodes.newAnydataBuilder(NormalizedAnydata.class)
                 .withNodeIdentifier(CONT_ANY_NODEID)
                 .withValue(NormalizedAnydata.of(
                     DefaultSchemaTreeInference.of(SCHEMA_CONTEXT, Absolute.of(CONT_QNAME)),
-                    Builders.containerBuilder().withNodeIdentifier(CONT_NODEID).build()))
+                    ImmutableNodes.newContainerBuilder().withNodeIdentifier(CONT_NODEID).build()))
                 .build())
             .build());
         normalizedNodeWriter.flush();
index 8a0ff89a64955fe9fec6c937628c77d49aacaa5c..de9ecc21ed4b934ef2a22e36ea4c37d7bc970b4a 100644 (file)
@@ -27,7 +27,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -99,9 +98,9 @@ class Bug5446Test extends AbstractXmlTest {
     }
 
     private static ContainerNode createDocNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
                 .withChild(ImmutableNodes.leafNode(IP_ADDRESS_QNAME, Base64.getDecoder().decode("fwAAAQ==")))
                 .build())
index e7131e2df0e189756c265c5a4ca7d4a6e9e387f0..b9e88729e2cc7f3b73c0901f71bfba51bf54ff4a 100644 (file)
@@ -28,10 +28,8 @@ import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -49,13 +47,13 @@ public class NormalizedNodeXmlTranslationTest extends AbstractXmlTest {
         final var containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container");
         final var leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf");
 
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(container)
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(new NodeIdentifier(augmentChoice1QName))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(augmentChoice2QName))
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(new NodeIdentifier(containerQName))
                         .withChild(ImmutableNodes.leafNode(leafQName, "leaf-value"))
                         .build())
@@ -65,76 +63,47 @@ public class NormalizedNodeXmlTranslationTest extends AbstractXmlTest {
     }
 
     private static ContainerNode withAttributes() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(getNodeIdentifier("container"))
-            .withChild(Builders.mapBuilder()
+            .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(getNodeIdentifier("list"))
-                .withChild(Builders.mapEntryBuilder()
+                .withChild(ImmutableNodes.newMapEntryBuilder()
                     .withNodeIdentifier(NodeIdentifierWithPredicates.of(getNodeIdentifier("list").getNodeType(),
                         getNodeIdentifier("uint32InList").getNodeType(), Uint32.valueOf(3)))
-                    .withChild(Builders.leafBuilder()
-                        .withNodeIdentifier(getNodeIdentifier("uint32InList"))
-                        .withValue(Uint32.valueOf(3))
-                        .build())
+                    .withChild(ImmutableNodes.leafNode(getNodeIdentifier("uint32InList"), Uint32.valueOf(3)))
                     .build())
                 .build())
-            .withChild(Builders.leafBuilder()
-                .withNodeIdentifier(getNodeIdentifier("boolean"))
-                .withValue(Boolean.FALSE)
-                .build())
-            .withChild(Builders.leafSetBuilder()
+            .withChild(ImmutableNodes.leafNode(getNodeIdentifier("boolean"), Boolean.FALSE))
+            .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                 .withNodeIdentifier(getNodeIdentifier("leafList"))
-                .withChild(Builders.leafSetEntryBuilder()
-                    .withNodeIdentifier(new NodeWithValue<>(getNodeIdentifier("leafList").getNodeType(), "a"))
-                    .withValue("a")
-                    .build())
+                .withChild(ImmutableNodes.leafSetEntry(getNodeIdentifier("leafList").getNodeType(), "a"))
                 .build())
             .build();
     }
 
     private static ContainerNode augmentChoiceHell() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(getNodeIdentifier("container"))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(getNodeIdentifier("ch2"))
-                .withChild(Builders.leafBuilder()
-                    .withNodeIdentifier(getNodeIdentifier("c2Leaf"))
-                    .withValue("2")
-                    .build())
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.leafNode(getNodeIdentifier("c2Leaf"), "2"))
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(getNodeIdentifier("c2DeepChoice"))
-                    .withChild(Builders.leafBuilder()
-                        .withNodeIdentifier(getNodeIdentifier("c2DeepChoiceCase1Leaf2"))
-                        .withValue("2")
-                        .build())
+                    .withChild(ImmutableNodes.leafNode(getNodeIdentifier("c2DeepChoiceCase1Leaf2"), "2"))
                     .build())
                 .build())
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(getNodeIdentifier("ch3"))
-                .withChild(Builders.leafBuilder()
-                    .withNodeIdentifier(getNodeIdentifier("c3Leaf"))
-                    .withValue("3")
-                    .build())
-                .build())
-            .withChild(Builders.leafBuilder()
-                .withNodeIdentifier(getNodeIdentifier("augLeaf"))
-                .withValue("augment")
+                .withChild(ImmutableNodes.leafNode(getNodeIdentifier("c3Leaf"), "3"))
                 .build())
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.leafNode(getNodeIdentifier("augLeaf"), "augment"))
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(getNodeIdentifier("ch"))
-                .withChild(Builders.leafBuilder()
-                    .withNodeIdentifier(getNodeIdentifier("c1Leaf")).withValue("1")
-                    .build())
-                .withChild(Builders.leafBuilder()
-                    .withNodeIdentifier(getNodeIdentifier("c1Leaf_AnotherAugment"))
-                    .withValue("1")
-                    .build())
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.leafNode(getNodeIdentifier("c1Leaf"), "1"))
+                .withChild(ImmutableNodes.leafNode(getNodeIdentifier("c1Leaf_AnotherAugment"), "1"))
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(getNodeIdentifier("deepChoice"))
-                    .withChild(Builders.leafBuilder()
-                        .withNodeIdentifier(getNodeIdentifier("deepLeafc1"))
-                        .withValue("1")
-                        .build())
+                    .withChild(ImmutableNodes.leafNode(getNodeIdentifier("deepLeafc1"), "1"))
                     .build())
                 .build())
             .build();
index 003575ddc34b3eb248903ba154f086bb99b23366..f493435fa52beefa533587104511bbe36506e89b 100644 (file)
@@ -25,10 +25,8 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -124,53 +122,47 @@ public class NormalizedNodesToXmlTest extends AbstractXmlTest {
     }
 
     private ContainerNode buildOuterContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(outerContainer))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer1))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myKeyedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myKeyedList, myKeyLeaf, "listkeyvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList1, "listleafvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList2, "listleafvalue2"))
                         .build())
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myKeyedList, myKeyLeaf, "listkeyvalue2"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList1, "listleafvalue12"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList2, "listleafvalue22"))
                         .build())
                     .build())
                 .withChild(ImmutableNodes.leafNode(myLeaf1, "value1"))
-                .withChild(Builders.leafSetBuilder()
+                .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myLeafList))
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(myLeafList, "lflvalue1"))
-                        .withValue("lflvalue1")
-                        .build())
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(myLeafList, "lflvalue2"))
-                        .withValue("lflvalue2")
-                        .build())
+                    .withChild(ImmutableNodes.leafSetEntry(myLeafList, "lflvalue1"))
+                    .withChild(ImmutableNodes.leafSetEntry(myLeafList, "lflvalue2"))
                     .build())
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer2))
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(innerContainer))
                     .withChild(ImmutableNodes.leafNode(myLeaf2, "value2"))
                     .build())
                 .withChild(ImmutableNodes.leafNode(myLeaf3, "value3"))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myChoice))
                     .withChild(ImmutableNodes.leafNode(myLeafInCase2, "case2value"))
                     .build())
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer3))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myDoublyKeyedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myDoublyKeyedList,
                             Map.of(myFirstKeyLeaf, "listkeyvalue1", mySecondKeyLeaf, "listkeyvalue2")))
                         .withChild(ImmutableNodes.leafNode(myLeafInList3, "listleafvalue1"))
index 010eb224d6aac948f995f45f93bc97d9152f9afd..475facb2a5b878f4409e05c3679691669a341765 100644 (file)
@@ -11,18 +11,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 
 import java.io.StringWriter;
-import java.util.ArrayList;
 import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ArgumentsSource;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.impl.schema.SchemaOrderedNormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.xmlunit.builder.DiffBuilder;
 
@@ -63,50 +59,34 @@ class SchemaOrderedNormalizedNodeWriterTest {
         var writer = XMLStreamNormalizedNodeStreamWriter.create(xmlStreamWriter, schemaContext);
 
         try (var nnw = new SchemaOrderedNormalizedNodeWriter(writer, schemaContext)) {
-
-            final var rule1Names = new ArrayList<MapEntryNode>();
-            rule1Names.add(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
-                createQName(FOO_NAMESPACE, NAME_NODE), "rule1"));
-            rule1Names.add(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
-                createQName(FOO_NAMESPACE, NAME_NODE), "rule2"));
-
-            final var rule2Names = new ArrayList<MapEntryNode>();
-            rule1Names.add(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
-                createQName(FOO_NAMESPACE, NAME_NODE), "rule3"));
-            rule1Names.add(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
-                createQName(FOO_NAMESPACE, NAME_NODE), "rule4"));
-
-            final var rules1 = Builders.orderedMapBuilder()
-                    .withNodeIdentifier(getNodeIdentifier(FOO_NAMESPACE, RULE_NODE))
-                    .withValue(rule1Names)
-                    .build();
-            final var rules2 = Builders.orderedMapBuilder()
-                    .withNodeIdentifier(getNodeIdentifier(FOO_NAMESPACE, RULE_NODE))
-                    .withValue(rule2Names)
-                    .build();
-
-            final var policyNodes = new ArrayList<MapEntryNode>();
-
-
-            final var pn1 = ImmutableNodes.mapEntryBuilder(createQName(FOO_NAMESPACE, POLICY_NODE),
-                        createQName(FOO_NAMESPACE, NAME_NODE), "policy1")
-                    .withChild(rules1)
-                    .build();
-            final var pn2 = ImmutableNodes.mapEntryBuilder(createQName(FOO_NAMESPACE, POLICY_NODE),
-                        createQName(FOO_NAMESPACE, NAME_NODE), "policy2")
-                    .withChild(rules2)
-                    .build();
-            policyNodes.add(pn1);
-            policyNodes.add(pn2);
-
-            final var policy = Builders.orderedMapBuilder()
+            nnw.write(ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(getNodeIdentifier(FOO_NAMESPACE, "root"))
+                .withChild(ImmutableNodes.newUserMapBuilder()
                     .withNodeIdentifier(getNodeIdentifier(FOO_NAMESPACE, POLICY_NODE))
-                    .withValue(policyNodes)
-                    .build();
-            final var root = Builders.containerBuilder()
-                    .withNodeIdentifier(getNodeIdentifier(FOO_NAMESPACE, "root"))
-                    .withChild(policy).build();
-            nnw.write(root);
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
+                        .withNodeIdentifier(NodeIdentifierWithPredicates.of(createQName(FOO_NAMESPACE, POLICY_NODE),
+                            createQName(FOO_NAMESPACE, NAME_NODE), "policy1"))
+                        .withChild(ImmutableNodes.newUserMapBuilder()
+                            .withNodeIdentifier(getNodeIdentifier(FOO_NAMESPACE, RULE_NODE))
+                            .withChild(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
+                                createQName(FOO_NAMESPACE, NAME_NODE), "rule1"))
+                            .withChild(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
+                                createQName(FOO_NAMESPACE, NAME_NODE), "rule2"))
+                            .withChild(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
+                                createQName(FOO_NAMESPACE, NAME_NODE), "rule3"))
+                            .withChild(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
+                                createQName(FOO_NAMESPACE, NAME_NODE), "rule4"))
+                            .build())
+                        .build())
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
+                        .withNodeIdentifier(NodeIdentifierWithPredicates.of(createQName(FOO_NAMESPACE, POLICY_NODE),
+                            createQName(FOO_NAMESPACE, NAME_NODE), "policy2"))
+                        .withChild(ImmutableNodes.newUserMapBuilder()
+                            .withNodeIdentifier(getNodeIdentifier(FOO_NAMESPACE, RULE_NODE))
+                            .build())
+                        .build())
+                    .build())
+                .build());
         }
 
         final var diff = DiffBuilder.compare(stringWriter.toString())
@@ -140,9 +120,9 @@ class SchemaOrderedNormalizedNodeWriterTest {
     @ParameterizedTest(name = "{0}")
     @ArgumentsSource(TestFactories.class)
     void testWriteOrder(final String factoryMode, final XMLOutputFactory factory) throws Exception {
-        final StringWriter stringWriter = new StringWriter();
-        final XMLStreamWriter xmlStreamWriter = factory.createXMLStreamWriter(stringWriter);
-        EffectiveModelContext schemaContext = YangParserTestUtils.parseYang("""
+        final var stringWriter = new StringWriter();
+        final var xmlStreamWriter = factory.createXMLStreamWriter(stringWriter);
+        final var schemaContext = YangParserTestUtils.parseYang("""
             module order {
               namespace "order";
               prefix "order";
@@ -162,9 +142,9 @@ class SchemaOrderedNormalizedNodeWriterTest {
         var writer = XMLStreamNormalizedNodeStreamWriter.create(xmlStreamWriter, schemaContext);
 
         try (var nnw = new SchemaOrderedNormalizedNodeWriter(writer, schemaContext)) {
-            nnw.write(Builders.containerBuilder()
+            nnw.write(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(getNodeIdentifier(ORDER_NAMESPACE, "root"))
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(getNodeIdentifier(ORDER_NAMESPACE, "cont"))
                     .withChild(ImmutableNodes.leafNode(createQName(ORDER_NAMESPACE, "content"), "content1"))
                     .build())
index e1924dcfe16999057c453e463c992415505ff96e..b2492c598f6810f008a99213fb3d2c1462e285f8 100644 (file)
@@ -24,10 +24,8 @@ import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
 public class SchemalessXMLStreamNormalizedNodeStreamWriterTest extends AbstractXmlTest {
@@ -122,77 +120,65 @@ public class SchemalessXMLStreamNormalizedNodeStreamWriterTest extends AbstractX
     }
 
     private ContainerNode buildOuterContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(outerContainer))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer1))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myKeyedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myKeyedList, myKeyLeaf, "listkeyvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList1, "listleafvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList2, "listleafvalue2"))
                         .build())
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myKeyedList, myKeyLeaf, "listkeyvalue2"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList1, "listleafvalue12"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList2, "listleafvalue22"))
                         .build())
                     .build())
-                .withChild(Builders.orderedMapBuilder()
+                .withChild(ImmutableNodes.newUserMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myOrderedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(
                             NodeIdentifierWithPredicates.of(myOrderedList, myKeyLeafInOrderedList, "olistkeyvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInOrderedList1, "olistleafvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInOrderedList2, "olistleafvalue2"))
                         .build())
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(
                             NodeIdentifierWithPredicates.of(myOrderedList, myKeyLeafInOrderedList, "olistkeyvalue2"))
                         .withChild(ImmutableNodes.leafNode(myLeafInOrderedList1, "olistleafvalue12"))
                         .withChild(ImmutableNodes.leafNode(myLeafInOrderedList2, "olistleafvalue22"))
                         .build())
                     .build())
-                .withChild(Builders.unkeyedListBuilder()
+                .withChild(ImmutableNodes.newUnkeyedListBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myUnkeyedList))
-                    .withChild(Builders.unkeyedListEntryBuilder()
+                    .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
                         .withNodeIdentifier(new NodeIdentifier(myUnkeyedList))
                         .withChild(ImmutableNodes.leafNode(myLeafInUnkeyedList, "foo"))
                         .build())
                     .build())
                 .withChild(ImmutableNodes.leafNode(myLeaf1, "value1"))
-                .withChild(Builders.leafSetBuilder()
+                .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myLeafList))
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(myLeafList, "lflvalue1"))
-                        .withValue("lflvalue1")
-                        .build())
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(myLeafList, "lflvalue2"))
-                        .withValue("lflvalue2")
-                        .build())
+                    .withChild(ImmutableNodes.leafSetEntry(myLeafList, "lflvalue1"))
+                    .withChild(ImmutableNodes.leafSetEntry(myLeafList, "lflvalue2"))
                     .build())
-                .withChild(Builders.orderedLeafSetBuilder()
+                .withChild(ImmutableNodes.newUserLeafSetBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myOrderedLeafList))
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(myOrderedLeafList, "olflvalue1"))
-                        .withValue("olflvalue1")
-                        .build())
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(myOrderedLeafList, "olflvalue2"))
-                        .withValue("olflvalue2")
-                        .build())
+                    .withChild(ImmutableNodes.leafSetEntry(myOrderedLeafList, "olflvalue1"))
+                    .withChild(ImmutableNodes.leafSetEntry(myOrderedLeafList, "olflvalue2"))
                     .build())
                 .build())
-            .withChild(Builders.containerBuilder().withNodeIdentifier(
+            .withChild(ImmutableNodes.newContainerBuilder().withNodeIdentifier(
                 new NodeIdentifier(myContainer2))
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(innerContainer))
                     .withChild(ImmutableNodes.leafNode(myLeaf2, "value2"))
                     .build())
                 .withChild(ImmutableNodes.leafNode(myLeaf3, "value3"))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myChoice))
                     .withChild(ImmutableNodes.leafNode(myLeafInCase2, "case2value"))
                     .build())
@@ -201,11 +187,11 @@ public class SchemalessXMLStreamNormalizedNodeStreamWriterTest extends AbstractX
 //                    .withValue(anyxmlDomSource)
 //                    .build())
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer3))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myDoublyKeyedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myDoublyKeyedList,
                             Map.of(myFirstKeyLeaf, "listkeyvalue1", mySecondKeyLeaf, "listkeyvalue2")))
                         .withChild(ImmutableNodes.leafNode(myLeafInList3, "listleafvalue1"))
index c787574ebdade10bf138f63204d5217be6595227..af9f873b14451c219c07011527e9a8f18427f09d 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.yangtools.yang.data.codec.xml;
 
 import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -28,16 +28,15 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -220,77 +219,79 @@ class XmlToNormalizedNodesTest {
 
     private static NormalizedNode buildOuterContainerNode() {
         // my-container-1
-        MapNode myKeyedListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_KEYED_LIST))
-                .withChild(Builders.mapEntryBuilder().withNodeIdentifier(
-                        NodeIdentifierWithPredicates.of(MY_KEYED_LIST, MY_KEY_LEAF, "listkeyvalue1"))
-                        .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_LIST_1))
-                                .withValue("listleafvalue1").build())
-                        .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_LIST_2))
-                                .withValue("listleafvalue2").build()).build())
-                .withChild(Builders.mapEntryBuilder().withNodeIdentifier(
-                        NodeIdentifierWithPredicates.of(MY_KEYED_LIST, MY_KEY_LEAF, "listkeyvalue2"))
-                        .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_LIST_1))
-                                .withValue("listleafvalue12").build())
-                        .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_LIST_2))
-                                .withValue("listleafvalue22").build()).build()).build();
-
-        LeafNode<?> myLeaf1Node = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_1))
-                .withValue("value1").build();
-
-        SystemLeafSetNode<?> myLeafListNode = Builders.leafSetBuilder()
-                .withNodeIdentifier(new NodeIdentifier(MY_LEAFLIST))
-                .withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(
-                        new NodeWithValue<>(MY_LEAFLIST, "lflvalue1")).withValue("lflvalue1").build())
-                .withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(
-                        new NodeWithValue<>(MY_LEAFLIST, "lflvalue2")).withValue("lflvalue2").build()).build();
-
-        ContainerNode myContainer1Node = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(MY_CONTAINER_1))
-                .withChild(myKeyedListNode)
-                .withChild(myLeaf1Node)
-                .withChild(myLeafListNode).build();
+        MapNode myKeyedListNode = ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MY_KEYED_LIST))
+            .withChild(ImmutableNodes.newMapEntryBuilder()
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_KEYED_LIST, MY_KEY_LEAF, "listkeyvalue1"))
+                .withChild(ImmutableNodes.leafNode(MY_LEAF_IN_LIST_1, "listleafvalue1"))
+                .withChild(ImmutableNodes.leafNode(MY_LEAF_IN_LIST_2, "listleafvalue2"))
+                .build())
+            .withChild(ImmutableNodes.newMapEntryBuilder().withNodeIdentifier(
+                NodeIdentifierWithPredicates.of(MY_KEYED_LIST, MY_KEY_LEAF, "listkeyvalue2"))
+                .withChild(ImmutableNodes.leafNode(MY_LEAF_IN_LIST_1, "listleafvalue12"))
+                .withChild(ImmutableNodes.leafNode(MY_LEAF_IN_LIST_2, "listleafvalue22"))
+                .build())
+            .build();
+
+        LeafNode<?> myLeaf1Node = ImmutableNodes.leafNode(MY_LEAF_1, "value1");
+
+        SystemLeafSetNode<?> myLeafListNode = ImmutableNodes.newSystemLeafSetBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MY_LEAFLIST))
+            .withChild(ImmutableNodes.leafSetEntry(MY_LEAFLIST, "lflvalue1"))
+            .withChild(ImmutableNodes.leafSetEntry(MY_LEAFLIST, "lflvalue2"))
+            .build();
+
+        ContainerNode myContainer1Node = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MY_CONTAINER_1))
+            .withChild(myKeyedListNode)
+            .withChild(myLeaf1Node)
+            .withChild(myLeafListNode)
+            .build();
 
         // my-container-2
-        ContainerNode innerContainerNode = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(INNER_CONTAINER))
-                .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_2))
-                        .withValue("value2").build()).build();
+        ContainerNode innerContainerNode = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(INNER_CONTAINER))
+            .withChild(ImmutableNodes.leafNode(MY_LEAF_2, "value2"))
+            .build();
 
-        LeafNode<?> myLeaf3Node = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_3))
-                .withValue("value3").build();
+        LeafNode<?> myLeaf3Node = ImmutableNodes.leafNode(MY_LEAF_3, "value3");
 
-        ChoiceNode myChoiceNode = Builders.choiceBuilder().withNodeIdentifier(new NodeIdentifier(MY_CHOICE))
-                .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_CASE_2))
-                        .withValue("case2value").build()).build();
+        ChoiceNode myChoiceNode = ImmutableNodes.newChoiceBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MY_CHOICE))
+            .withChild(ImmutableNodes.leafNode(MY_LEAF_IN_CASE_2, "case2value"))
+            .build();
 
-        ContainerNode myContainer2Node = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(MY_CONTAINER_2))
-                .withChild(innerContainerNode)
-                .withChild(myLeaf3Node)
-                .withChild(myChoiceNode).build();
+        ContainerNode myContainer2Node = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MY_CONTAINER_2))
+            .withChild(innerContainerNode)
+            .withChild(myLeaf3Node)
+            .withChild(myChoiceNode)
+            .build();
 
         // my-container-3
         Map<QName, Object> keys = new HashMap<>();
         keys.put(MY_FIRST_KEY_LEAF, "listkeyvalue1");
         keys.put(MY_SECOND_KEY_LEAF, "listkeyvalue2");
 
-        MapNode myDoublyKeyedListNode = Builders.mapBuilder()
+        MapNode myDoublyKeyedListNode = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MY_DOUBLY_KEYED_LIST))
-                .withChild(Builders.mapEntryBuilder().withNodeIdentifier(
-                        NodeIdentifierWithPredicates.of(MY_DOUBLY_KEYED_LIST, keys))
-                        .withChild(Builders.leafBuilder().withNodeIdentifier(
-                                new NodeIdentifier(MY_LEAF_IN_LIST_3)).withValue("listleafvalue1").build()).build())
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_DOUBLY_KEYED_LIST, keys))
+                    .withChild(ImmutableNodes.leafNode(MY_LEAF_IN_LIST_3, "listleafvalue1"))
+                    .build())
                 .build();
 
-        ContainerNode myContainer3Node = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(MY_CONTAINER_3))
-                .withChild(myDoublyKeyedListNode).build();
-
-        ContainerNode outerContainerNode = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(OUTER_CONTAINER))
-                .withChild(myContainer1Node)
-                .withChild(myContainer2Node)
-                .withChild(myContainer3Node).build();
+        ContainerNode myContainer3Node = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MY_CONTAINER_3))
+            .withChild(myDoublyKeyedListNode)
+            .build();
+
+        ContainerNode outerContainerNode = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(OUTER_CONTAINER))
+            .withChild(myContainer1Node)
+            .withChild(myContainer2Node)
+            .withChild(myContainer3Node)
+            .build();
 
         return outerContainerNode;
     }
index 9672f715416ef607905dad36e068f6ea221d7b59..1c02a1baf5d85781b9cf5362c8b8641e7be35322 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -68,22 +67,22 @@ class YT1107Test {
         final var xmlParser = XmlParserStream.create(streamWriter, Inference.ofDataTreePath(schemaContext, PARENT));
         xmlParser.parse(reader);
 
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(PARENT))
-            .withChild(Builders.mapBuilder()
+            .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ADMIN))
-                .withChild(Builders.mapEntryBuilder()
+                .withChild(ImmutableNodes.newMapEntryBuilder()
                     .withNodeIdentifier(NodeIdentifierWithPredicates.of(ADMIN, NAME, "John"))
                     .withChild(ImmutableNodes.leafNode(NAME, "John"))
                     .build())
                 .build())
-            .withChild(Builders.mapBuilder()
+            .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(USER))
-                .withChild(Builders.mapEntryBuilder()
+                .withChild(ImmutableNodes.newMapEntryBuilder()
                     .withNodeIdentifier(NodeIdentifierWithPredicates.of(USER, NAME, "Freud"))
                     .withChild(ImmutableNodes.leafNode(NAME, "Freud"))
                     .build())
-                .withChild(Builders.mapEntryBuilder()
+                .withChild(ImmutableNodes.newMapEntryBuilder()
                     .withNodeIdentifier(NodeIdentifierWithPredicates.of(USER, NAME, "Bob"))
                     .withChild(ImmutableNodes.leafNode(NAME, "Bob"))
                     .build())
index 631cd03f2459a7fda2bca07255d07d18812e8269..02dd336701023195c0aeb1a626a50e65928bd215 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.xmlunit.builder.DiffBuilder;
@@ -77,12 +77,9 @@ class YT1108Test {
     void testLeafOfIdentityRefTypeNNToXmlSerialization(final String factoryMode, final XMLOutputFactory factory)
             throws Exception {
         final var diff = DiffBuilder
-            .compare(serializeToXml(factory, Builders.containerBuilder()
+            .compare(serializeToXml(factory, ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(NodeIdentifier.create(LEAF_CONTAINER))
-                .withChild(Builders.leafBuilder()
-                    .withNodeIdentifier(NodeIdentifier.create(IDENTITYREF_LEAF))
-                    .withValue(IDENT_ONE)
-                    .build())
+                .withChild(ImmutableNodes.leafNode(IDENTITYREF_LEAF, IDENT_ONE))
                 .build()))
             .withTest("""
                 <?xml version="1.0" encoding="UTF-8"?>
@@ -101,12 +98,9 @@ class YT1108Test {
     void testLeafOfUnionWithIdentityRefNNToXmlSerialization(final String factoryMode, final XMLOutputFactory factory)
             throws Exception {
         final var diff = DiffBuilder
-            .compare(serializeToXml(factory, Builders.containerBuilder()
+            .compare(serializeToXml(factory, ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(NodeIdentifier.create(LEAF_CONTAINER))
-                .withChild(Builders.leafBuilder()
-                    .withNodeIdentifier(NodeIdentifier.create(UNION_IDENTITYREF_LEAF))
-                    .withValue(IDENT_ONE)
-                    .build())
+                .withChild(ImmutableNodes.leafNode(UNION_IDENTITYREF_LEAF, IDENT_ONE))
                 .build()))
             .withTest("""
                 <?xml version="1.0" encoding="UTF-8"?>
index 3233dd8078a79b1ec2be6e2146e5a8b727f0fc86..dd0f105a1aae8925e1bab720d1d6c53eac73baae 100644 (file)
@@ -19,7 +19,6 @@ import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.common.YangDataName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -63,11 +62,11 @@ class YT1472Test {
                 <error-message>Data already exists; cannot create new resource</error-message>
               </error>
             </errors>""")));
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(NodeIdentifier.create(QName.create(RESTCONF_MODULE, "errors")))
-            .withChild(Builders.unkeyedListBuilder()
+            .withChild(ImmutableNodes.newUnkeyedListBuilder()
                 .withNodeIdentifier(ERROR_NID)
-                .withChild(Builders.unkeyedListEntryBuilder()
+                .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
                     .withNodeIdentifier(ERROR_NID)
                     .withChild(ImmutableNodes.leafNode(QName.create(RESTCONF_MODULE, "error-type"), "protocol"))
                     .withChild(ImmutableNodes.leafNode(QName.create(RESTCONF_MODULE, "error-tag"), "data-exists"))
index 2525441a598031341cfcb99c9af2d84695dc2d48..a77645d1cd202c120482204c79797d31463c4658 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -71,7 +70,7 @@ class YT1543Test {
             try (var nnWriter = NormalizedNodeWriter.forStreamWriter(xmlWriter)) {
                 // Contrived: we have a document for foo's 'foo' container, with 'leaf' pointing to an instance of bar's
                 //            'bar' list item, whose key points to baz's 'baz' container.
-                nnWriter.write(Builders.containerBuilder()
+                nnWriter.write(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(QName.create("foons", "foo")))
                     .withChild(ImmutableNodes.leafNode(QName.create("foons", "leaf"), IID))
                     .build());
index 97850d2ee7d064d02529c7b85a1d7e436cf38400..407626d4a385fb98235e5dabf53c66922509c226 100644 (file)
@@ -13,7 +13,6 @@ import com.google.common.annotations.Beta;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode.BuilderFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizationResult;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -25,12 +24,10 @@ import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 @Beta
 public final class ReusableImmutableNormalizedNodeStreamWriter extends ImmutableNormalizedNodeStreamWriter
         implements ReusableStreamReceiver {
-    private static final BuilderFactory BUILDER_FACTORY = ImmutableNodes.builderFactory();
-
     private final NormalizationResultBuilder builder;
 
-    private final LeafSetEntryNode.Builder<?> leafsetEntryBuilder = BUILDER_FACTORY.newLeafSetEntryBuilder();
-    private final LeafNode.Builder<?> leafNodeBuilder = BUILDER_FACTORY.newLeafBuilder();
+    private final LeafSetEntryNode.Builder<?> leafsetEntryBuilder = ImmutableNodes.newLeafSetEntryBuilder();
+    private final LeafNode.Builder<?> leafNodeBuilder = ImmutableNodes.newLeafBuilder();
 
     private ReusableImmutableNormalizedNodeStreamWriter(final NormalizationResultBuilder builder) {
         super(builder);
index 1a0f7cca84554ebf9336c371d49078b2936ba366..8b7127eaae27ad2e5df3fd9ab5d3ba1b93e42e8b 100644 (file)
@@ -21,7 +21,6 @@ import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -115,83 +114,78 @@ class ImmutableNormalizedNodeStreamWriterTest {
     }
 
     private ContainerNode buildOuterContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(outerContainer))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer1))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myKeyedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myKeyedList, myKeyLeaf, "listkeyvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList1, "listleafvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList2, "listleafvalue2"))
                         .build())
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myKeyedList, myKeyLeaf, "listkeyvalue2"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList1, "listleafvalue12"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList2, "listleafvalue22"))
                         .build())
                     .build())
-                .withChild(Builders.orderedMapBuilder()
+                .withChild(ImmutableNodes.newUserMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myOrderedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(
                             NodeIdentifierWithPredicates.of(myOrderedList, myKeyLeafInOrderedList, "olistkeyvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInOrderedList1, "olistleafvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInOrderedList2, "olistleafvalue2"))
                         .build())
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(
                             NodeIdentifierWithPredicates.of(myOrderedList, myKeyLeafInOrderedList, "olistkeyvalue2"))
                         .withChild(ImmutableNodes.leafNode(myLeafInOrderedList1, "olistleafvalue12"))
                         .withChild(ImmutableNodes.leafNode(myLeafInOrderedList2, "olistleafvalue22"))
                         .build())
                     .build())
-                .withChild(Builders.unkeyedListBuilder()
+                .withChild(ImmutableNodes.newUnkeyedListBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myUnkeyedList))
-                    .withValue(List.of(Builders.unkeyedListEntryBuilder()
+                    .withValue(List.of(ImmutableNodes.newUnkeyedListEntryBuilder()
                         .withNodeIdentifier(new NodeIdentifier(myLeafInUnkeyedList))
                         .withChild(ImmutableNodes.leafNode(myLeafInUnkeyedList, "foo"))
                         .build()))
                     .build())
                 .withChild(ImmutableNodes.leafNode(myLeaf1, "value1"))
-                .withChild(Builders.leafSetBuilder()
+                .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myLeafList))
-                    .withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(
-                            new NodeWithValue<>(myLeafList, "lflvalue1")).withValue("lflvalue1").build())
-                    .withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(
-                            new NodeWithValue<>(myLeafList, "lflvalue2")).withValue("lflvalue2").build())
+                    .withChild(ImmutableNodes.leafSetEntry(myLeafList, "lflvalue1"))
+                    .withChild(ImmutableNodes.leafSetEntry(myLeafList, "lflvalue2"))
                     .build())
-                .withChild(Builders.orderedLeafSetBuilder()
+                .withChild(ImmutableNodes.newUserLeafSetBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myOrderedLeafList))
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(
-                            new NodeWithValue<>(myOrderedLeafList, "olflvalue1")).withValue("olflvalue1").build())
-                    .withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(
-                            new NodeWithValue<>(myOrderedLeafList, "olflvalue2")).withValue("olflvalue2").build())
+                    .withChild(ImmutableNodes.leafSetEntry(myOrderedLeafList, "olflvalue1"))
+                    .withChild(ImmutableNodes.leafSetEntry(myOrderedLeafList, "olflvalue2"))
                     .build())
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer2))
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(innerContainer))
                     .withChild(ImmutableNodes.leafNode(myLeaf2, "value2"))
                     .build())
                 .withChild(ImmutableNodes.leafNode(myLeaf3, "value3"))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myChoice))
                     .withChild(ImmutableNodes.leafNode(myLeafInCase2, "case2value"))
                     .build())
-                .withChild(Builders.anyXmlBuilder()
+                .withChild(ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
                     .withNodeIdentifier(new NodeIdentifier(myAnyxml))
                     .withValue(anyxmlDomSource)
                     .build())
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer3))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myDoublyKeyedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myDoublyKeyedList,
                             Map.of(myFirstKeyLeaf, "listkeyvalue1", mySecondKeyLeaf, "listkeyvalue2")))
                         .withChild(ImmutableNodes.leafNode(myLeafInList3, "listleafvalue1"))
index 5b2134f5c25733871ea5552526f2ec90fa81b462..685806ea79f736cd9de4961854d88bc55dd7660e 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.fromInstanceId;
 
 import com.google.common.collect.ImmutableMap;
 import java.util.Map;
@@ -23,6 +24,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -58,25 +60,22 @@ class InstanceIdToNodesTest {
 
     @Test
     void testListLastChildOverride() {
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(rootContainer)
-            .withChild(Builders.mapBuilder()
+            .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(outerList)
-                .withChild(Builders.mapEntryBuilder()
+                .withChild(ImmutableNodes.newMapEntryBuilder()
                     .withNodeIdentifier(outerListWithKey)
-                    .withChild(Builders.leafBuilder()
-                        .withNodeIdentifier(new NodeIdentifier(ID))
-                        .withValue(1)
-                        .build())
+                    .withChild(ImmutableNodes.leafNode(new NodeIdentifier(ID), 1))
                     .build())
                 .build())
             .build(),
-            ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of(rootContainer, outerList, outerListWithKey)));
+            fromInstanceId(ctx, YangInstanceIdentifier.of(rootContainer, outerList, outerListWithKey)));
     }
 
     @Test
     void testLeafList() {
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(rootContainer)
             .withChild(Builders.<String>orderedLeafSetBuilder()
                 .withNodeIdentifier(leafList)
@@ -86,13 +85,14 @@ class InstanceIdToNodesTest {
                     .build())
                 .build())
             .build(),
-            ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of(rootContainer, leafList, leafListWithValue)));
+            fromInstanceId(ctx, YangInstanceIdentifier.of(rootContainer, leafList, leafListWithValue)));
     }
 
     @Test
     void testEmptyInstanceIdentifier() {
-        assertEquals(ImmutableNodes.containerNode(SchemaContext.NAME),
-            ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of()));
+        assertEquals(ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
+            .build(), fromInstanceId(ctx, YangInstanceIdentifier.of()));
     }
 
     @Test
@@ -101,7 +101,7 @@ class InstanceIdToNodesTest {
         final var id = NodeIdentifierWithPredicates.of(TWO_KEY_LIST.getNodeType(), misordered);
         assertArrayEquals(new Object[] { BAR, FOO }, id.keySet().toArray());
 
-        final var filter = ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of(TWO_KEY_LIST, id));
+        final var filter = fromInstanceId(ctx, YangInstanceIdentifier.of(TWO_KEY_LIST, id));
         final var value = assertInstanceOf(MapNode.class, filter).body();
         assertEquals(1, value.size());
         final var entry = value.iterator().next();
index 686d46effcbe041cd4eca93dad81fd1b3edfa8e4..d6a2393c840b83ea2d98fd69a9ee4c4148b48b27 100644 (file)
@@ -13,12 +13,13 @@ import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
 class NormalizedDataBuilderTest {
     @Test
     void testSchemaUnaware() {
         // Container
-        final var builder = Builders.containerBuilder()
+        final var builder = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(getNodeIdentifier("container"))
             .withChild(Builders.<String>leafBuilder()
                 .withNodeIdentifier(getNodeIdentifier("leaf"))
@@ -32,14 +33,14 @@ class NormalizedDataBuilderTest {
                     .withValue(3)
                     .build())
                 .build())
-            .withChild(Builders.mapBuilder()
+            .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(getNodeIdentifier("list"))
-                .withChild(Builders.mapEntryBuilder()
+                .withChild(ImmutableNodes.newMapEntryBuilder()
                     .withChild(Builders.<Integer>leafBuilder()
                         .withNodeIdentifier(getNodeIdentifier("uint32InList"))
                         .withValue(1)
                         .build())
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(getNodeIdentifier("containerInList"))
                         .build())
                     .withNodeIdentifier(NodeIdentifierWithPredicates.of(getNodeIdentifier("list").getNodeType(),
index bb7e38f790cf2457b84b1e5dc46c8fd5710ca447..bc054d4148eadeb164252dbb45492f4f0e844c28 100644 (file)
@@ -5,21 +5,19 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
 /*
 * Schema structure of document is:
@@ -86,14 +84,18 @@ class NormalizedNodeUtilsTest {
      * @return A test document
      */
     private static NormalizedNode createDocumentOne() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
-            .withChild(mapNodeBuilder(LIST_A_QNAME)
-                .withChild(mapEntry(LIST_A_QNAME, LEAF_A_QNAME, FOO))
-                .withChild(mapEntryBuilder(LIST_A_QNAME, LEAF_A_QNAME, BAR)
-                    .withChild(mapNodeBuilder(LIST_B_QNAME)
-                        .withChild(mapEntry(LIST_B_QNAME, LEAF_B_QNAME, ONE))
-                        .withChild(mapEntry(LIST_B_QNAME, LEAF_B_QNAME, TWO))
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(LIST_A_QNAME))
+                .withChild(ImmutableNodes.mapEntry(LIST_A_QNAME, LEAF_A_QNAME, FOO))
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_A_QNAME, LEAF_A_QNAME, BAR))
+                    .withChild(ImmutableNodes.leafNode(LEAF_A_QNAME, BAR))
+                    .withChild(ImmutableNodes.newSystemMapBuilder()
+                        .withNodeIdentifier(new NodeIdentifier(LIST_B_QNAME))
+                        .withChild(ImmutableNodes.mapEntry(LIST_B_QNAME, LEAF_B_QNAME, ONE))
+                        .withChild(ImmutableNodes.mapEntry(LIST_B_QNAME, LEAF_B_QNAME, TWO))
                         .build())
                     .build())
                 .build())
index f83be38a4fdb3903d79e48c664a5c0eb9041918f..a4b1a31a78673a8ef73a17b0b81b1226d48c3437 100644 (file)
@@ -23,25 +23,25 @@ class OrderingEqualityTest {
 
     @Test
     void testUserMap() {
-        final var firstMap = Builders.orderedMapBuilder()
+        final var firstMap = ImmutableNodes.newUserMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "two"))
                 .withChild(ImmutableNodes.leafNode(BAR, "two"))
                 .build())
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
                 .withChild(ImmutableNodes.leafNode(BAR, "one"))
                 .build())
             .build();
 
-        final var secondMap = Builders.orderedMapBuilder()
+        final var secondMap = ImmutableNodes.newUserMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
                 .withChild(ImmutableNodes.leafNode(BAR, "one"))
                 .build())
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "two"))
                 .withChild(ImmutableNodes.leafNode(BAR, "two"))
                 .build())
@@ -51,13 +51,13 @@ class OrderingEqualityTest {
         assertNotEquals(firstMap, secondMap);
         assertNotEquals(secondMap, firstMap);
 
-        final var thirdMap = Builders.orderedMapBuilder()
+        final var thirdMap = ImmutableNodes.newUserMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
                 .withChild(ImmutableNodes.leafNode(BAR, "one"))
                 .build())
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "two"))
                 .withChild(ImmutableNodes.leafNode(BAR, "two"))
                 .build())
@@ -70,13 +70,13 @@ class OrderingEqualityTest {
         assertEquals(secondMap.hashCode(), thirdMap.hashCode());
 
         // Although this map looks as secondMap, it is not equal
-        final var systemMap = Builders.mapBuilder()
+        final var systemMap = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
                 .withChild(ImmutableNodes.leafNode(BAR, "one"))
                 .build())
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "two"))
                 .withChild(ImmutableNodes.leafNode(BAR, "two"))
                 .build())
@@ -89,24 +89,24 @@ class OrderingEqualityTest {
 
     @Test
     void testSystemMap() {
-        final var firstMap = Builders.mapBuilder()
+        final var firstMap = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
                 .withChild(ImmutableNodes.leafNode(BAR, "one"))
                 .build())
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "two"))
                 .withChild(ImmutableNodes.leafNode(BAR, "two"))
                 .build())
             .build();
-        final var secondMap = Builders.mapBuilder()
+        final var secondMap = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "two"))
                 .withChild(ImmutableNodes.leafNode(BAR, "two"))
                 .build())
-            .withChild(Builders.mapEntryBuilder()
+            .withChild(ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
                 .withChild(ImmutableNodes.leafNode(BAR, "one"))
                 .build())
index f0dffe122478b0bf18f72972d8449fa8f57964ce..a37d8968d7f9347a632d1981d165e22f288c8670 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode.BuilderFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -29,7 +28,6 @@ import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 class YT1417Test {
     private static final QName FOO = QName.create("foo", "foo");
     private static final QName BAR = QName.create("foo", "bar");
-    private static final BuilderFactory BUILDER_FACTORY = ImmutableNodes.builderFactory();
 
     @Test
     void testContainerNodeEquality() {
@@ -38,26 +36,26 @@ class YT1417Test {
         doReturn(1).when(mock).size();
         doReturn(ImmutableNodes.leafNode(BAR, "abc")).when(mock).childByArg(new NodeIdentifier(BAR));
 
-        assertEquals(BUILDER_FACTORY.newContainerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafNode(BAR, "abc"))
             .build(), mock);
 
         // Mismatched identifier
-        assertNotEquals(BUILDER_FACTORY.newContainerBuilder()
+        assertNotEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(BAR))
             .withChild(ImmutableNodes.leafNode(BAR, "abc"))
             .build(), mock);
 
         // Mismatched child size
-        assertNotEquals(BUILDER_FACTORY.newContainerBuilder()
+        assertNotEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafNode(FOO, "abc"))
             .withChild(ImmutableNodes.leafNode(BAR, "abc"))
             .build(), mock);
 
         // Mismatched child
-        assertNotEquals(BUILDER_FACTORY.newContainerBuilder()
+        assertNotEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafNode(FOO, "abc"))
             .build(), mock);
@@ -70,26 +68,26 @@ class YT1417Test {
         doReturn(1).when(mock).size();
         doReturn(ImmutableNodes.leafSetEntry(FOO, "abc")).when(mock).childByArg(new NodeWithValue<>(FOO, "abc"));
 
-        assertEquals(BUILDER_FACTORY.newSystemLeafSetBuilder()
+        assertEquals(ImmutableNodes.newSystemLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafSetEntry(FOO, "abc"))
             .build(), mock);
 
         // Mismatched identifier
-        assertNotEquals(BUILDER_FACTORY.newSystemLeafSetBuilder()
+        assertNotEquals(ImmutableNodes.newSystemLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(BAR))
             .withChild(ImmutableNodes.leafSetEntry(BAR, "abc"))
             .build(), mock);
 
         // Mismatched child size
-        assertNotEquals(BUILDER_FACTORY.newSystemLeafSetBuilder()
+        assertNotEquals(ImmutableNodes.newSystemLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafSetEntry(FOO, "abc"))
             .withChild(ImmutableNodes.leafSetEntry(FOO, "def"))
             .build(), mock);
 
         // Mismatched child
-        assertNotEquals(BUILDER_FACTORY.newSystemLeafSetBuilder()
+        assertNotEquals(ImmutableNodes.newSystemLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafSetEntry(FOO, "def"))
             .build(), mock);
@@ -103,21 +101,21 @@ class YT1417Test {
             ImmutableNodes.leafSetEntry(FOO, "abc"),
             ImmutableNodes.leafSetEntry(FOO, "def"))).when(mock).body();
 
-        assertEquals(BUILDER_FACTORY.newUserLeafSetBuilder()
+        assertEquals(ImmutableNodes.newUserLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafSetEntry(FOO, "abc"))
             .withChild(ImmutableNodes.leafSetEntry(FOO, "def"))
             .build(), mock);
 
         // Mismatched identifier
-        assertNotEquals(BUILDER_FACTORY.newUserLeafSetBuilder()
+        assertNotEquals(ImmutableNodes.newUserLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(BAR))
             .withChild(ImmutableNodes.leafSetEntry(BAR, "abc"))
             .withChild(ImmutableNodes.leafSetEntry(BAR, "def"))
             .build(), mock);
 
         // Mismatched child order
-        assertNotEquals(BUILDER_FACTORY.newUserLeafSetBuilder()
+        assertNotEquals(ImmutableNodes.newUserLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(ImmutableNodes.leafSetEntry(FOO, "def"))
             .withChild(ImmutableNodes.leafSetEntry(FOO, "abc"))
index fead6f65e2d02c98314662b6af233b3851a2cfea..fd84192406c009489b0bbd1fdfab79eba5cd30b0 100644 (file)
@@ -12,11 +12,21 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
+import org.opendaylight.yangtools.yang.data.api.schema.AnydataNode;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyxmlNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode.BuilderFactory;
+import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
 import org.opendaylight.yangtools.yang.data.spi.node.impl.ImmutableBuilderFactory;
 import org.opendaylight.yangtools.yang.data.spi.node.impl.ImmutableLeafNode;
 import org.opendaylight.yangtools.yang.data.spi.node.impl.ImmutableLeafSetEntryNode;
@@ -65,6 +75,10 @@ public final class ImmutableNodes {
         return BUILDER_FACTORY.newMapEntryBuilder(name.size()).withNodeIdentifier(name).build();
     }
 
+    public static @NonNull MapEntryNode mapEntry(final QName listName, final QName keyName, final Object keyValue) {
+        return mapEntry(NodeIdentifierWithPredicates.of(listName, keyName, keyValue));
+    }
+
     public static <T> @NonNull LeafSetEntryNode<T> leafSetEntry(final NodeWithValue<T> name) {
         return ImmutableLeafSetEntryNode.of(name);
     }
@@ -72,4 +86,56 @@ public final class ImmutableNodes {
     public static <T> @NonNull LeafSetEntryNode<T> leafSetEntry(final QName name, final T value) {
         return leafSetEntry(new NodeWithValue<>(name, value));
     }
+
+    public static <T> AnydataNode.@NonNull Builder<T> newAnydataBuilder(final Class<T> objectModel) {
+        return BUILDER_FACTORY.newAnydataBuilder(objectModel);
+    }
+
+    public static <T> AnyxmlNode.@NonNull Builder<T, AnyxmlNode<T>> newAnyxmlBuilder(final Class<T> objectModel) {
+        return BUILDER_FACTORY.newAnyxmlBuilder(objectModel);
+    }
+
+    public static ChoiceNode.@NonNull Builder newChoiceBuilder() {
+        return BUILDER_FACTORY.newChoiceBuilder();
+    }
+
+    public static ContainerNode.@NonNull Builder newContainerBuilder() {
+        return BUILDER_FACTORY.newContainerBuilder();
+    }
+
+    public static MapEntryNode.@NonNull Builder newMapEntryBuilder() {
+        return BUILDER_FACTORY.newMapEntryBuilder();
+    }
+
+    public static SystemMapNode.@NonNull Builder newSystemMapBuilder() {
+        return BUILDER_FACTORY.newSystemMapBuilder();
+    }
+
+    public static UserMapNode.@NonNull Builder newUserMapBuilder() {
+        return BUILDER_FACTORY.newUserMapBuilder();
+    }
+
+    public static UnkeyedListEntryNode.@NonNull Builder newUnkeyedListEntryBuilder() {
+        return BUILDER_FACTORY.newUnkeyedListEntryBuilder();
+    }
+
+    public static UnkeyedListNode.@NonNull Builder newUnkeyedListBuilder() {
+        return BUILDER_FACTORY.newUnkeyedListBuilder();
+    }
+
+    public static <T> LeafNode.@NonNull Builder<T> newLeafBuilder() {
+        return BUILDER_FACTORY.newLeafBuilder();
+    }
+
+    public static <T> LeafSetEntryNode.@NonNull Builder<T> newLeafSetEntryBuilder() {
+        return BUILDER_FACTORY.newLeafSetEntryBuilder();
+    }
+
+    public static <T> SystemLeafSetNode.@NonNull Builder<T> newSystemLeafSetBuilder() {
+        return BUILDER_FACTORY.newSystemLeafSetBuilder();
+    }
+
+    public static <T> UserLeafSetNode.@NonNull Builder<T> newUserLeafSetBuilder() {
+        return BUILDER_FACTORY.newUserLeafSetBuilder();
+    }
 }
index 14141c2ff7929835ca2e12e2d62518d4e603c4fc..7de4f229b64ba576d6d6dbf4aa3a370fda40dcc6 100644 (file)
@@ -50,19 +50,19 @@ class BuilderTest {
     @Test
     void immutableOrderedMapBuilderTest() {
         final var mapEntryPath = NodeIdentifierWithPredicates.of(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 1);
-        final var orderedMapNodeCreateNull = BUILDER_FACTORY.newUserMapBuilder()
+        final var orderedMapNodeCreateNull = ImmutableNodes.newUserMapBuilder()
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .withChild(LIST_MAIN_CHILD_1)
                 .addChild(LIST_MAIN_CHILD_2)
                 .withValue(List.of(LIST_MAIN_CHILD_3))
                 .build();
-        final var orderedMapNodeCreateSize = BUILDER_FACTORY.newUserMapBuilder(SIZE)
+        final var orderedMapNodeCreateSize = ImmutableNodes.builderFactory().newUserMapBuilder(SIZE)
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
         final var orderedMapNodeCreateNode = ImmutableUserMapNodeBuilder.create(orderedMapNodeCreateNull)
                 .removeChild(mapEntryPath)
                 .build();
-        final var orderedMapNodeSchemaAware = BUILDER_FACTORY.newUserMapBuilder()
+        final var orderedMapNodeSchemaAware = ImmutableNodes.newUserMapBuilder()
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .withChild(LIST_MAIN_CHILD_1)
                 .build();
@@ -80,18 +80,18 @@ class BuilderTest {
 
     @Test
     void immutableUserLeafSetNodeBuilderTest() {
-        final var orderedLeafSet = BUILDER_FACTORY.<String>newUserLeafSetBuilder()
+        final var orderedLeafSet = ImmutableNodes.<String>newUserLeafSetBuilder()
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .withChild(LEAF_SET_ENTRY_NODE)
                 .withChildValue("baz")
                 .removeChild(BAR_PATH)
                 .build();
-        final var orderedMapNodeSchemaAware = BUILDER_FACTORY.newUserLeafSetBuilder()
+        final var orderedMapNodeSchemaAware = ImmutableNodes.newUserLeafSetBuilder()
             .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
             .withChildValue("baz")
             .build();
 
-        assertNotNull(BUILDER_FACTORY.newAnyxmlBuilder(DOMSource.class));
+        assertNotNull(ImmutableNodes.newAnyxmlBuilder(DOMSource.class));
         assertEquals(1, orderedLeafSet.size());
         assertEquals("baz", orderedLeafSet.childAt(0).body());
         assertNull(orderedLeafSet.childByArg(BAR_PATH));
@@ -110,7 +110,7 @@ class BuilderTest {
 
     @Test
     void immutableUnkeyedListEntryNodeBuilderTest() {
-        final var unkeyedListEntryNode = BUILDER_FACTORY.newUnkeyedListEntryBuilder()
+        final var unkeyedListEntryNode = ImmutableNodes.newUnkeyedListEntryBuilder()
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
         final var unkeyedListEntryNodeSize = BUILDER_FACTORY.newUnkeyedListEntryBuilder(1)
@@ -123,10 +123,10 @@ class BuilderTest {
 
     @Test
     void immutableUnkeyedListNodeBuilderTest() {
-        final var unkeyedListEntryNode = BUILDER_FACTORY.newUnkeyedListEntryBuilder()
+        final var unkeyedListEntryNode = ImmutableNodes.newUnkeyedListEntryBuilder()
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF)
                 .build();
-        final var immutableUnkeyedListNodeBuilder = BUILDER_FACTORY.newUnkeyedListBuilder();
+        final var immutableUnkeyedListNodeBuilder = ImmutableNodes.newUnkeyedListBuilder();
         final var unkeyedListNode = immutableUnkeyedListNodeBuilder
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .addChild(unkeyedListEntryNode)
@@ -176,12 +176,12 @@ class BuilderTest {
 
     @Test
     void immutableUnkeyedListNodeBuilderExceptionTest() {
-        final var builder = BUILDER_FACTORY.newUnkeyedListBuilder().withNodeIdentifier(NODE_IDENTIFIER_LEAF);
+        final var builder = ImmutableNodes.newUnkeyedListBuilder().withNodeIdentifier(NODE_IDENTIFIER_LEAF);
         assertThrows(UnsupportedOperationException.class, () -> builder.removeChild(NODE_IDENTIFIER_LIST));
     }
 
     private static UserMapNode getImmutableUserMapNode() {
-        return BUILDER_FACTORY.newUserMapBuilder()
+        return ImmutableNodes.newUserMapBuilder()
             .withNodeIdentifier(NODE_IDENTIFIER_LIST)
             .withChild(LIST_MAIN_CHILD_1)
             .build();
index 916133b0a15106dec55978f7bad14fbedcbf255e..2e45119ddccd9e08f6573af70b00eb7a802136e4 100644 (file)
@@ -7,10 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.tree.impl;
 
-import java.util.List;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.AnydataNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -22,8 +21,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
 abstract class AbstractPrettyTreeTest {
     protected static final QName ROOT_QNAME = QName.create(
@@ -51,12 +49,9 @@ abstract class AbstractPrettyTreeTest {
     protected static final QName USER_MAP_QNAME = QName.create(ROOT_QNAME, "user-map");
     protected static final QName USER_MAP_ENTRY_QNAME = QName.create(ROOT_QNAME, "user-map-entry");
 
-    protected static final QName UNKEYED_LIST_QNAME = QName.create(ROOT_QNAME,
-            "unkeyed-list");
-    protected static final QName UNKEYED_LIST_ENTRY_QNAME = QName.create(ROOT_QNAME,
-            "unkeyed-list-entry");
-    protected static final QName UNKEYED_LIST_LEAF_QNAME = QName.create(ROOT_QNAME,
-            "unkeyed-list-leaf");
+    protected static final QName UNKEYED_LIST_QNAME = QName.create(ROOT_QNAME, "unkeyed-list");
+    protected static final QName UNKEYED_LIST_ENTRY_QNAME = QName.create(ROOT_QNAME, "unkeyed-list-entry");
+    protected static final QName UNKEYED_LIST_LEAF_QNAME = QName.create(ROOT_QNAME, "unkeyed-list-leaf");
 
     protected static final QName ANY_DATA_QNAME = QName.create(ROOT_QNAME, "any-data");
 
@@ -94,7 +89,7 @@ abstract class AbstractPrettyTreeTest {
      * @return A test node
      */
     protected static ContainerNode createContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
             .withChild(createMapNode())
             .withChild(createChoiceNode())
@@ -109,15 +104,19 @@ abstract class AbstractPrettyTreeTest {
     }
 
     protected static MapNode createMapNode() {
-        return ImmutableNodes.mapNodeBuilder(LIST_A_QNAME)
+        return ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(LIST_A_QNAME))
             .withChild(ImmutableNodes.mapEntry(LIST_A_QNAME, LEAF_A_QNAME, "foo"))
             .withChild(createMapEntryNode())
             .build();
     }
 
     protected static MapEntryNode createMapEntryNode() {
-        return ImmutableNodes.mapEntryBuilder(LIST_A_QNAME, LEAF_A_QNAME, "bar")
-            .withChild(ImmutableNodes.mapNodeBuilder(LIST_B_QNAME)
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_A_QNAME, LEAF_A_QNAME, "bar"))
+            .withChild(ImmutableNodes.leafNode(LEAF_A_QNAME, "bar"))
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(LIST_B_QNAME))
                 .withChild(ImmutableNodes.mapEntry(LIST_B_QNAME, LEAF_B_QNAME, "one"))
                 .withChild(ImmutableNodes.mapEntry(LIST_B_QNAME, LEAF_B_QNAME, "two"))
                 .build())
@@ -125,7 +124,7 @@ abstract class AbstractPrettyTreeTest {
     }
 
     protected static ChoiceNode createChoiceNode() {
-        return Builders.choiceBuilder()
+        return ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(NodeIdentifier.create(CHOICE_QNAME))
                 .withChild(createAugmentedLeafNode())
                 .build();
@@ -136,9 +135,10 @@ abstract class AbstractPrettyTreeTest {
     }
 
     protected static ContainerNode createContainerFromAnotherNamespace() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(ANOTHER_QNAME))
-            .withChild(ImmutableNodes.mapNodeBuilder(LIST_ANOTHER_NAMESPACE_QNAME)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(LIST_ANOTHER_NAMESPACE_QNAME))
                 .withChild(ImmutableNodes.mapEntry(LIST_ANOTHER_NAMESPACE_QNAME, LEAF_ANOTHER_NAMESPACE_QNAME,
                     "Leaf from another namespace value"))
                 .build())
@@ -151,28 +151,22 @@ abstract class AbstractPrettyTreeTest {
 
     protected static LeafSetNode<String> createLeafSetNode() {
         final var value = "Leaf set value";
-        return Builders.<String>leafSetBuilder()
+        return ImmutableNodes.<String>newSystemLeafSetBuilder()
             .withNodeIdentifier(NodeIdentifier.create(LEAF_SET_QNAME))
-            .withValue(List.of(Builders.<String>leafSetEntryBuilder()
-                .withNodeIdentifier(new NodeWithValue<>(LEAF_SET_QNAME, value))
-                .withValue(value)
-                .build()))
+            .withChild(ImmutableNodes.leafSetEntry(LEAF_SET_QNAME, value))
             .build();
     }
 
     protected static UserLeafSetNode<String> createUserLeafSetNode() {
         final var value = "User leaf set value";
-        return Builders.<String>orderedLeafSetBuilder()
+        return ImmutableNodes.<String>newUserLeafSetBuilder()
             .withNodeIdentifier(NodeIdentifier.create(USER_LEAF_SET_QNAME))
-            .withChild(Builders.<String>leafSetEntryBuilder()
-                .withNodeIdentifier(new NodeWithValue<>(USER_LEAF_SET_QNAME, value))
-                .withValue(value)
-                .build())
+            .withChild(ImmutableNodes.leafSetEntry(USER_LEAF_SET_QNAME, value))
             .build();
     }
 
     protected static UserMapNode createUserMapNode() {
-        return Builders.orderedMapBuilder()
+        return ImmutableNodes.newUserMapBuilder()
             .withNodeIdentifier(NodeIdentifier.create(USER_MAP_QNAME))
             .withChild(createUserMapEntryNode())
             .build();
@@ -183,23 +177,23 @@ abstract class AbstractPrettyTreeTest {
     }
 
     protected static UnkeyedListNode createUnkeyedListNode() {
-        return Builders.unkeyedListBuilder()
+        return ImmutableNodes.newUnkeyedListBuilder()
             .withNodeIdentifier(NodeIdentifier.create(UNKEYED_LIST_QNAME))
             .withChild(createUnkeyedListEntryNode())
             .build();
     }
 
     protected static UnkeyedListEntryNode createUnkeyedListEntryNode() {
-        return Builders.unkeyedListEntryBuilder()
+        return ImmutableNodes.newUnkeyedListEntryBuilder()
             .withNodeIdentifier(NodeIdentifier.create(UNKEYED_LIST_ENTRY_QNAME))
             .withChild(ImmutableNodes.leafNode(UNKEYED_LIST_LEAF_QNAME, "Unkeyed list leaf value"))
             .build();
     }
 
     protected static AnydataNode<String> createAnyDataNode() {
-        return Builders.anydataBuilder(String.class)
-                .withNodeIdentifier(NodeIdentifier.create(ANY_DATA_QNAME))
-                .withValue("Any data value")
-                .build();
+        return ImmutableNodes.newAnydataBuilder(String.class)
+            .withNodeIdentifier(NodeIdentifier.create(ANY_DATA_QNAME))
+            .withValue("Any data value")
+            .build();
     }
 }
index eb6ff6cd8a52f55ac8ea62fb2c789deb562f66db..e77f81ca0e97430e4476356f850e70942217fc1a 100644 (file)
@@ -14,8 +14,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
@@ -36,18 +35,18 @@ class Bug2690Test extends AbstractTestModelTest {
     void testWriteMerge1() throws DataValidationFailedException {
         final var fooEntryNode = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
         final var barEntryNode = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2);
-        final var mapNode1 = ImmutableNodes.mapNodeBuilder()
+        final var mapNode1 = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
                 .withChild(fooEntryNode).build();
-        final var mapNode2 = ImmutableNodes.mapNodeBuilder()
+        final var mapNode2 = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
                 .withChild(barEntryNode).build();
 
-        final var cont1 = Builders.containerBuilder()
+        final var cont1 = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
                 .withChild(mapNode1).build();
 
-        final var cont2 = Builders.containerBuilder()
+        final var cont2 = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
                 .withChild(mapNode2).build();
 
index c4b31d99ac8360fa5e39c3a9084febb2e2f561e2..27aef385c178153ff4d1ac9fc123517aa7a89dba 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.junit.jupiter.api.Test;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
@@ -31,7 +32,8 @@ class Bug3674Test extends AbstractTestModelTest {
 
         // Create the top-level container
         final var mod = tree.takeSnapshot().newModification();
-        mod.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        mod.write(TestModel.TEST_PATH,
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build());
         mod.ready();
         tree.commit(tree.prepare(mod));
 
index 13544ac2d09edb88b50bbc853b96f236ef3e5ac0..cedfbdd3a24667151cc6ae32d0b6b491ca8c27bf 100644 (file)
@@ -19,8 +19,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
@@ -94,7 +93,7 @@ class Bug4295Test {
         DataTreeModification modification = inMemoryDataTree.takeSnapshot().newModification();
         modification.merge(path, createRootContainerBuilder()
             .withChild(createSubRootContainerBuilder()
-                .withChild(ImmutableNodes.mapNodeBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(NodeIdentifier.create(outerList))
                     .withChild(createOuterListEntry("1", "o-1"))
                     .withChild(createOuterListEntry("2", "o-2"))
@@ -121,7 +120,7 @@ class Bug4295Test {
         /*  MERGE */
         ContainerNode rootContainerNode = createRootContainerBuilder()
             .withChild(createSubRootContainerBuilder()
-                .withChild(ImmutableNodes.mapNodeBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(NodeIdentifier.create(outerList))
                     .withChild(createOuterListEntry("3", "o-3"))
                     .withChild(createOuterListEntry("4", "o-4"))
@@ -174,15 +173,15 @@ class Bug4295Test {
     }
 
     private DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createRootContainerBuilder() {
-        return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(root));
+        return ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(root));
     }
 
     private DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createSubRootContainerBuilder() {
-        return  Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(subRoot));
+        return  ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(subRoot));
     }
 
     private CollectionNodeBuilder<MapEntryNode, SystemMapNode> createInnerListBuilder() {
-        return ImmutableNodes.mapNodeBuilder().withNodeIdentifier(NodeIdentifier.create(innerList));
+        return ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(NodeIdentifier.create(innerList));
     }
 
     private NodeIdentifierWithPredicates createInnerListEntryPath(final String keyValue) {
@@ -194,12 +193,18 @@ class Bug4295Test {
     }
 
     private MapEntryNode createOuterListEntry(final String keyValue, final String leafValue) {
-        return ImmutableNodes.mapEntryBuilder(outerList, oid, keyValue)
-                .withChild(ImmutableNodes.leafNode(oleaf, leafValue)).build();
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(outerList, oid, keyValue))
+            .withChild(ImmutableNodes.leafNode(oid, keyValue))
+            .withChild(ImmutableNodes.leafNode(oleaf, leafValue))
+            .build();
     }
 
     private MapEntryNode createInnerListEntry(final String keyValue, final String leafValue) {
-        return ImmutableNodes.mapEntryBuilder(innerList, iid, keyValue)
-                .withChild(ImmutableNodes.leafNode(ileaf, leafValue)).build();
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(innerList, iid, keyValue))
+            .withChild(ImmutableNodes.leafNode(iid, keyValue))
+            .withChild(ImmutableNodes.leafNode(ileaf, leafValue))
+            .build();
     }
 }
\ No newline at end of file
index 320624ab2171e7642439cb31e91a4505263c1266..1b376b54220fbffbd63f1bd18fa2df3afd7e1bf1 100644 (file)
@@ -30,8 +30,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.DistinctNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
@@ -64,11 +63,11 @@ class Bug4454Test {
     private static final YangInstanceIdentifier MIN_MAX_LEAF_LIST_PATH =
         YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node(MIN_MAX_LEAF_LIST_QNAME).build();
 
-    private final MapEntryNode fooEntryNodeWithValue = Builders.mapEntryBuilder()
+    private final MapEntryNode fooEntryNodeWithValue = ImmutableNodes.newMapEntryBuilder()
         .withNodeIdentifier(NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo"))
         .withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "footest"))
         .build();
-    private final MapEntryNode bazEntryNodeWithValue = Builders.mapEntryBuilder()
+    private final MapEntryNode bazEntryNodeWithValue = ImmutableNodes.newMapEntryBuilder()
         .withNodeIdentifier(NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "baz"))
         .withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "baztest"))
         .build();
@@ -78,18 +77,18 @@ class Bug4454Test {
             "bar");
     private final MapEntryNode bazEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
             "baz");
-    private final SystemMapNode mapNodeBazFuzWithNodes = ImmutableNodes.mapNodeBuilder()
+    private final SystemMapNode mapNodeBazFuzWithNodes = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
             .withChild(bazEntryNode).withChild(bazEntryNodeWithValue).withChild(fooEntryNode)
             .build();
-    private final SystemMapNode mapNodeFooWithNodes = ImmutableNodes.mapNodeBuilder()
+    private final SystemMapNode mapNodeFooWithNodes = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
             .withChild(fooEntryNode).withChild(fooEntryNodeWithValue).withChild(barEntryNode).withChild(bazEntryNode)
             .build();
-    private final SystemMapNode mapNodeBar = ImmutableNodes.mapNodeBuilder()
+    private final SystemMapNode mapNodeBar = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
             .withChild(barEntryNode).build();
-    private final SystemMapNode mapNodeBaz = ImmutableNodes.mapNodeBuilder()
+    private final SystemMapNode mapNodeBaz = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
             .withChild(bazEntryNode).build();
 
@@ -165,7 +164,9 @@ class Bug4454Test {
         final var initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
         final var modificationTree = initialDataTreeSnapshot.newModification();
 
-        modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.containerNode(MASTER_CONTAINER_QNAME));
+        modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MASTER_CONTAINER_QNAME))
+            .build());
         modificationTree.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(modificationTree));
     }
@@ -308,14 +309,10 @@ class Bug4454Test {
         final var barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar");
         final var gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo");
 
-        final var barLeafSetEntry = Builders.<String>leafSetEntryBuilder()
-                .withNodeIdentifier(barPath)
-                .withValue("bar").build();
-        final var gooLeafSetEntry = Builders.<String>leafSetEntryBuilder()
-                .withNodeIdentifier(gooPath)
-                .withValue("goo").build();
+        final var barLeafSetEntry = ImmutableNodes.leafSetEntry(barPath);
+        final var gooLeafSetEntry = ImmutableNodes.leafSetEntry(gooPath);
 
-        final var fooLeafSetNode = Builders.leafSetBuilder()
+        final var fooLeafSetNode = ImmutableNodes.newSystemLeafSetBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME))
                 .withChildValue("foo")
                 .build();
@@ -405,7 +402,8 @@ class Bug4454Test {
 
         final var minMaxLeafBaz = PRESENCE_PATH.node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
 
-        modificationTree.write(PRESENCE_PATH, ImmutableNodes.containerNode(PRESENCE_QNAME));
+        modificationTree.write(PRESENCE_PATH,
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(PRESENCE_QNAME)).build());
         modificationTree.write(PRESENCE_MIN_MAX_LIST_PATH, mapNodeFooWithNodes);
         modificationTree.merge(PRESENCE_MIN_MAX_LIST_PATH, mapNodeBar);
         modificationTree.merge(PRESENCE_MIN_MAX_LIST_PATH, mapNodeBaz);
@@ -429,7 +427,7 @@ class Bug4454Test {
     void minMaxListNoMinMaxDeleteTest() throws DataValidationFailedException {
         final var fooEntryNoMinMaxNode =
                 ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME, "foo");
-        final var mapNode1 = ImmutableNodes.mapNodeBuilder()
+        final var mapNode1 = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME_NO_MINMAX))
                 .withChild(fooEntryNoMinMaxNode).build();
 
index a387d05dc6665251ec0c296cf5f4dcd989195200..5226cafa4b025c10f92b9bc0e45e639f4dd8d21b 100644 (file)
@@ -19,7 +19,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -48,7 +47,7 @@ class Bug5830Test {
         final var inMemoryDataTree = new InMemoryDataTreeFactory().create(
                 DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
 
-        final var taskNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(TASK)).build();
+        final var taskNode = ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(TASK)).build();
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER, TASK), taskNode);
         modificationTree.ready();
@@ -270,7 +269,7 @@ class Bug5830Test {
     private static void testContainerIsNotPresent(final EffectiveModelContext schemaContext)
             throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree(schemaContext);
-        final var taskEntryNode = Builders.mapEntryBuilder()
+        final var taskEntryNode = ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data"))
@@ -291,7 +290,7 @@ class Bug5830Test {
             throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree(schemaContext);
 
-        final var taskEntryNode = Builders.mapEntryBuilder()
+        final var taskEntryNode = ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data"))
@@ -312,7 +311,7 @@ class Bug5830Test {
             throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree(schemaContext);
 
-        final var taskEntryNode = Builders.mapEntryBuilder()
+        final var taskEntryNode = ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data"))
@@ -333,7 +332,7 @@ class Bug5830Test {
             final boolean withPresenceContianer) throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree(schemaContext);
 
-        final var taskEntryNode = Builders.mapEntryBuilder()
+        final var taskEntryNode = ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data"))
@@ -352,7 +351,7 @@ class Bug5830Test {
     }
 
     private static DataContainerChild createTaskDataContainer(final boolean withMandatoryNode) {
-        final var taskDataBuilder = Builders.containerBuilder()
+        final var taskDataBuilder = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TASK_DATA))
                 .withChild(ImmutableNodes.leafNode(OTHER_DATA, "foo"));
         if (withMandatoryNode) {
@@ -362,18 +361,18 @@ class Bug5830Test {
     }
 
     private static DataContainerChild createTaskDataMultipleContainer(final boolean withPresenceContianer) {
-        final var nonPresenceContainerBuilder = Builders.containerBuilder()
+        final var nonPresenceContainerBuilder = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(NON_PRESENCE_CONTAINER))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(NON_PRESENCE_CONTAINER_2))
                 .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF_2, "mandatory leaf data 2")).build());
 
         if (withPresenceContianer) {
-            nonPresenceContainerBuilder.withChild(Builders.containerBuilder()
+            nonPresenceContainerBuilder.withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(PRESENCE_CONTAINER_2)).build());
         }
 
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TASK_DATA))
             .withChild(ImmutableNodes.leafNode(OTHER_DATA, "foo"))
             .withChild(ImmutableNodes.leafNode(MANDATORY_DATA, "mandatory-data-value"))
index 4f11d702129b961e526ed6a40c2d18d60e9c792d..093fde6ed9763c970f1e7e2c214704e3b18b9d48 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -83,12 +82,12 @@ class Bug5968MergeTest {
         final var inMemoryDataTree = new InMemoryDataTreeFactory().create(
                 DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
 
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT));
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.merge(YangInstanceIdentifier.of(ROOT),
             withMapNode ? root.withChild(
-                Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST)).build()).build()
+                ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST)).build()).build()
                 : root.build());
         modificationTree.ready();
 
@@ -108,7 +107,7 @@ class Bug5968MergeTest {
         final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
 
         final var myList = createMap(true);
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
@@ -169,7 +168,7 @@ class Bug5968MergeTest {
     }
 
     private static SystemMapNode createMap(final boolean mandatoryDataMissing) throws DataValidationFailedException {
-        return Builders.mapBuilder()
+        return ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MY_LIST))
             .withChild(mandatoryDataMissing ? createMapEntry("1", "common-value")
                 : createMapEntry("1", "mandatory-value", "common-value"))
@@ -189,7 +188,7 @@ class Bug5968MergeTest {
 
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object mandatoryLeafValue,
             final Object commonLeafValue) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
@@ -197,14 +196,14 @@ class Bug5968MergeTest {
     }
 
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
     }
 
     private static MapEntryNode createMapEntryM(final Object listIdValue, final Object mandatoryLeafValue) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue)).build();
@@ -215,7 +214,7 @@ class Bug5968MergeTest {
         final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
 
         final var myList = createMap(false);
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
@@ -299,17 +298,17 @@ class Bug5968MergeTest {
 
     private static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> createEmptyMapEntryBuilder(
             final Object listIdValue) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue));
     }
 
     private static CollectionNodeBuilder<MapEntryNode, SystemMapNode> createMapBuilder() {
-        return Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST));
+        return ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST));
     }
 
     private static DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createContainerBuilder() {
-        return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(ROOT));
+        return ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(ROOT));
     }
 
     @Test
index 104e7b84dcb83dc3a59f5f0edd8fc9233b420882..476dd46213abf6505994a5aaeab4341881bedc4e 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -81,14 +80,15 @@ class Bug5968Test {
         final var inMemoryDataTree = new InMemoryDataTreeFactory().create(
                 DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
 
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT));
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
-        modificationTree.write(
-                YangInstanceIdentifier.of(ROOT),
-                withMapNode ? root.withChild(
-                        Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST)).build()).build() : root
-                        .build());
+        modificationTree.write(YangInstanceIdentifier.of(ROOT), withMapNode
+            ? root.withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(MY_LIST))
+                .build())
+                .build()
+                : root.build());
         modificationTree.ready();
 
         inMemoryDataTree.validate(modificationTree);
@@ -107,7 +107,7 @@ class Bug5968Test {
         final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
 
         final var myList = createMap(true);
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
@@ -167,7 +167,7 @@ class Bug5968Test {
     }
 
     private static SystemMapNode createMap(final boolean mandatoryDataMissing) {
-        return Builders.mapBuilder()
+        return ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MY_LIST))
             .withChild(mandatoryDataMissing ? createMapEntry("1", "common-value")
                 : createMapEntry("1", "mandatory-value", "common-value"))
@@ -187,7 +187,7 @@ class Bug5968Test {
 
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object mandatoryLeafValue,
             final Object commonLeafValue) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
@@ -195,7 +195,7 @@ class Bug5968Test {
     }
 
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
                 .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
@@ -206,7 +206,7 @@ class Bug5968Test {
         final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
 
         final var myList = createMap(false);
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
index 100061a14e338f683b0c21042cccc8cb99e911db..e07bd3eb4f0cebef2a0733aaacb0fccea6ed2f11 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -77,7 +76,7 @@ class Bug8291Test {
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(
             YangInstanceIdentifier.of(NodeIdentifierWithPredicates.of(OUTER_LIST, OUTER_LIST_ID, 1)).node(INNER_LIST),
-            Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(INNER_LIST)).build());
+            ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(INNER_LIST)).build());
 
         modificationTree.ready();
         inMemoryDataTree.validate(modificationTree);
@@ -89,7 +88,7 @@ class Bug8291Test {
             throws DataValidationFailedException {
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
-        final var outerListMapEntry = Builders.mapEntryBuilder()
+        final var outerListMapEntry = ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(OUTER_LIST, OUTER_LIST_ID, 1))
             .withChild(ImmutableNodes.leafNode(OUTER_LIST_ID, 1))
             .build();
index 8473d30d1ef98742b29e4a3ebea2a840b31ba122..33e28dc3f71c62580607b1d014790b1974508a48 100644 (file)
@@ -9,14 +9,13 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
 
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -85,11 +84,11 @@ class CaseAugmentTest {
     void testWriteAugment() throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree();
 
-        final var container = Builders.containerBuilder()
+        final var container = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(CHOICE_ID)
-                .withChild(leafNode(C1L2_QNAME, "leaf-value"))
+                .withChild(ImmutableNodes.leafNode(C1L2_QNAME, "leaf-value"))
                 .build())
             .build();
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
@@ -106,13 +105,13 @@ class CaseAugmentTest {
         final var inMemoryDataTree = initDataTree();
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
-        modificationTree.write(TestModel.TEST_PATH, Builders.containerBuilder()
+        modificationTree.write(TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(CHOICE_ID)
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
-                .withChild(leafNode(C1L2_QNAME, "leaf-value"))
-                .withChild(leafNode(C1L3_QNAME, "leaf-value"))
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
+                .withChild(ImmutableNodes.leafNode(C1L2_QNAME, "leaf-value"))
+                .withChild(ImmutableNodes.leafNode(C1L3_QNAME, "leaf-value"))
                 .build())
             .build());
         modificationTree.ready();
@@ -125,12 +124,12 @@ class CaseAugmentTest {
     @Test
     void testWriteConflict() throws DataValidationFailedException {
         final var modificationTree = initDataTree().takeSnapshot().newModification();
-        modificationTree.write(TestModel.TEST_PATH, Builders.containerBuilder()
+        modificationTree.write(TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(CHOICE_ID)
-                .withChild(leafNode(C1L2_QNAME, "leaf-value"))
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
+                .withChild(ImmutableNodes.leafNode(C1L2_QNAME, "leaf-value"))
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
                 .build())
             .build());
 
index 02e102745089c3e53130a707dc4338038ff46d8c..cb84390e06752b233d1396cfa52daad4acbc5bb9 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
 
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
@@ -17,8 +16,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
@@ -50,13 +48,13 @@ class CaseExclusionTest {
     void testCorrectCaseWrite() throws DataValidationFailedException {
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
-        final var container = Builders
-                .containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-                .withChild(
-                        Builders.choiceBuilder().withNodeIdentifier(choice1Id)
-                                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
-                                .build()).build();
+        final var container = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+            .withChild(ImmutableNodes.newChoiceBuilder()
+                .withNodeIdentifier(choice1Id)
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
+                .build())
+            .build();
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, container);
         modificationTree.ready();
@@ -70,17 +68,17 @@ class CaseExclusionTest {
     void testCaseExclusion() {
         assertThrows(IllegalArgumentException.class, () -> {
             final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
-
-            final var container = Builders
-                .containerBuilder()
+            final var container = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-                .withChild(
-                    Builders.choiceBuilder()
-                        .withNodeIdentifier(choice1Id)
-                        .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
-                        .withChild(
-                            ImmutableNodes.containerNode(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                        .build()).build();
+                .withChild(ImmutableNodes.newChoiceBuilder()
+                    .withNodeIdentifier(choice1Id)
+                    .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
+                    .withChild(ImmutableNodes.newContainerBuilder()
+                        .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
+                        .build())
+                    .build())
+                .build();
+
             try {
                 final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
                 modificationTree.write(TestModel.TEST_PATH, container);
@@ -100,7 +98,7 @@ class CaseExclusionTest {
     void testCaseExclusionOnChoiceWrite() {
         assertThrows(IllegalArgumentException.class, () -> {
             // Container write
-            final var container = Builders.containerBuilder()
+            final var container = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
             final var modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
@@ -113,9 +111,12 @@ class CaseExclusionTest {
 
             // Choice write
             final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
-            final var choice = Builders.choiceBuilder().withNodeIdentifier(choice1Id)
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
-                .withChild(ImmutableNodes.containerNode(QName.create(TestModel.TEST_QNAME, "case2-cont"))).build();
+            final var choice = ImmutableNodes.newChoiceBuilder().withNodeIdentifier(choice1Id)
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
+                .withChild(ImmutableNodes.newContainerBuilder()
+                    .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
+                    .build())
+                .build();
 
             try {
                 final var modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
index 37075f74a59da0968fb722dd206e8855f5afeefc..8c286fa48fb288a030d1f67edc439e1fb838879c 100644 (file)
@@ -17,12 +17,12 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.ma
 import java.util.Optional;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.ConflictingModificationAppliedException;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
@@ -66,14 +66,14 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     }
 
     private static ContainerNode createFooTestContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
             .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(FOO_NODE).build())
             .build();
     }
 
     private static ContainerNode createBarTestContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
             .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(BAR_NODE).build())
             .build();
@@ -93,8 +93,10 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
         final var modificationTree1 = initialDataTreeSnapshot.newModification();
         final var modificationTree2 = initialDataTreeSnapshot.newModification();
 
-        modificationTree1.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        modificationTree2.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        modificationTree1.write(TestModel.TEST_PATH,
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build());
+        modificationTree2.write(TestModel.TEST_PATH,
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build());
 
         modificationTree1.ready();
         modificationTree2.ready();
@@ -122,8 +124,10 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
         final var modificationTree1 = initialDataTreeSnapshot.newModification();
         final var modificationTree2 = initialDataTreeSnapshot.newModification();
 
-        modificationTree1.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        modificationTree2.merge(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        modificationTree1.write(TestModel.TEST_PATH,
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build());
+        modificationTree2.merge(TestModel.TEST_PATH,
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build());
 
         modificationTree1.ready();
         modificationTree2.ready();
@@ -253,7 +257,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void writeWriteFooBar1stLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final var initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -287,7 +291,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void writeMergeFooBar1stLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final var initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -316,7 +320,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void mergeWriteFooBar1stLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final var initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -351,7 +355,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void mergeMergeFooBar1stLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final var initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -380,7 +384,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void deleteWriteFooBar1stLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final var initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -414,7 +418,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void deleteMergeFooBar1stLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final var initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -442,7 +446,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void writeWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
             .build());
         initialDataTreeModification.ready();
@@ -473,7 +477,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void writeMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
             .build());
         initialDataTreeModification.ready();
@@ -504,7 +508,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void mergeWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
             .build());
         initialDataTreeModification.ready();
@@ -535,7 +539,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void mergeMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
             .build());
         initialDataTreeModification.ready();
@@ -566,7 +570,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void deleteWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
             .build());
         initialDataTreeModification.ready();
@@ -601,7 +605,7 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     @Test
     void deleteMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
         initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
             .build());
         initialDataTreeModification.ready();
@@ -632,4 +636,8 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
         final var snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertFalse(snapshotAfterCommits.readNode(TestModel.TEST_PATH).isPresent());
     }
+
+    private static ContainerNode emptyContainer(final QName name) {
+        return ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(name)).build();
+    }
 }
index fcdbda3baca9e02fe1815af2ad9cf6d999ab6d6e..f4a0a16a50979f4993993b9c9b6f3012935fa3f2 100644 (file)
@@ -8,8 +8,6 @@
 package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
@@ -19,7 +17,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.SchemaValidationFailedException;
 import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
@@ -37,12 +35,12 @@ class ConfigStatementValidationTest extends AbstractTestModelTest {
             .builder(TestModel.OUTER_LIST_PATH).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
             .build();
 
-    private static final MapEntryNode INNER_FOO_ENTRY_NODE = mapEntry(TestModel.INNER_LIST_QNAME,
+    private static final MapEntryNode INNER_FOO_ENTRY_NODE = ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME,
             TestModel.NAME_QNAME, "foo");
 
     private static final MapEntryNode INNER_BAR_ENTRY_NODE =
             mapEntryBuilder(QName.create(TestModel.TEST_QNAME, "inner-list2"), TestModel.NAME_QNAME, "foo")
-                .withChild(leafNode(TestModel.VALUE_QNAME, "value")).build();
+                .withChild(ImmutableNodes.leafNode(TestModel.VALUE_QNAME, "value")).build();
 
     private static final MapEntryNode FOO_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
             .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(INNER_FOO_ENTRY_NODE)
@@ -55,13 +53,13 @@ class ConfigStatementValidationTest extends AbstractTestModelTest {
             .build();
 
     private static ContainerNode createFooTestContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
             .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(FOO_NODE).build()).build();
     }
 
     private static ContainerNode createBarTestContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
             .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(BAR_NODE).build()).build();
     }
@@ -118,8 +116,10 @@ class ConfigStatementValidationTest extends AbstractTestModelTest {
             final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
             final var case2ContId = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont"));
             final var ii = TestModel.TEST_PATH.node(choice1Id).node(case2ContId);
-            final var case2Cont = Builders.containerBuilder().withNodeIdentifier(case2ContId)
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value")).build();
+            final var case2Cont = ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(case2ContId)
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
+                .build();
 
             final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
             modificationTree.write(ii, case2Cont);
@@ -134,8 +134,10 @@ class ConfigStatementValidationTest extends AbstractTestModelTest {
                 DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT);
             final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
             final var ii = TestModel.TEST_PATH.node(choice1Id);
-            final var choice1 = Builders.choiceBuilder().withNodeIdentifier(choice1Id)
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value")).build();
+            final var choice1 = ImmutableNodes.newChoiceBuilder()
+                .withNodeIdentifier(choice1Id)
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
+                .build();
 
             final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
             modificationTree.write(ii, choice1);
index be73feb80cdcc0f7d36555449d5c6db7766b8f67..32542f66844be6320402ac2a8467297eabf3b21c 100644 (file)
@@ -18,8 +18,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
@@ -38,9 +37,9 @@ class DataTreeCandidatesTest extends AbstractTestModelTest {
     void setUp() throws Exception {
         dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
 
-        final var testContainer = Builders.containerBuilder()
+        final var testContainer = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
                 .build())
             .build();
@@ -92,7 +91,9 @@ class DataTreeCandidatesTest extends AbstractTestModelTest {
     @Test
     void testEmptyMergeOnContainer() throws DataValidationFailedException {
         final var modification = dataTree.takeSnapshot().newModification();
-        modification.merge(TestModel.NON_PRESENCE_PATH, ImmutableNodes.containerNode(TestModel.NON_PRESENCE_QNAME));
+        modification.merge(TestModel.NON_PRESENCE_PATH, ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.NON_PRESENCE_QNAME))
+            .build());
         modification.ready();
         dataTree.validate(modification);
 
@@ -108,7 +109,9 @@ class DataTreeCandidatesTest extends AbstractTestModelTest {
     @Test
     void testEmptyWriteOnContainer() throws DataValidationFailedException {
         final var modification = dataTree.takeSnapshot().newModification();
-        modification.write(TestModel.NON_PRESENCE_PATH, ImmutableNodes.containerNode(TestModel.NON_PRESENCE_QNAME));
+        modification.write(TestModel.NON_PRESENCE_PATH, ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.NON_PRESENCE_QNAME))
+            .build());
         modification.ready();
         dataTree.validate(modification);
 
@@ -125,7 +128,9 @@ class DataTreeCandidatesTest extends AbstractTestModelTest {
     void testEmptyMergesOnDeleted() throws DataValidationFailedException {
         final var modification = dataTree.takeSnapshot().newModification();
         modification.delete(TestModel.NON_PRESENCE_PATH);
-        modification.merge(TestModel.DEEP_CHOICE_PATH, ImmutableNodes.choiceNode(TestModel.DEEP_CHOICE_QNAME));
+        modification.merge(TestModel.DEEP_CHOICE_PATH, ImmutableNodes.newChoiceBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.DEEP_CHOICE_QNAME))
+            .build());
         modification.ready();
         dataTree.validate(modification);
 
@@ -149,8 +154,12 @@ class DataTreeCandidatesTest extends AbstractTestModelTest {
 
         // Issue an empty merge on it and a child choice
         modification = dataTree.takeSnapshot().newModification();
-        modification.merge(TestModel.NON_PRESENCE_PATH, ImmutableNodes.containerNode(TestModel.NON_PRESENCE_QNAME));
-        modification.merge(TestModel.DEEP_CHOICE_PATH, ImmutableNodes.choiceNode(TestModel.DEEP_CHOICE_QNAME));
+        modification.merge(TestModel.NON_PRESENCE_PATH, ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.NON_PRESENCE_QNAME))
+            .build());
+        modification.merge(TestModel.DEEP_CHOICE_PATH, ImmutableNodes.newChoiceBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.DEEP_CHOICE_QNAME))
+            .build());
         modification.ready();
         dataTree.validate(modification);
 
index b3a11da4a38166507af8a9c8561389cb7d51cf09..bd70e0df742bce81b0ba25f137ab359b93ccedb2 100644 (file)
@@ -12,7 +12,8 @@ import static org.junit.jupiter.api.Assertions.fail;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.ConflictingModificationAppliedException;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -32,7 +33,8 @@ class ErrorReportingTest extends AbstractTestModelTest {
     void writeWithoutParentExisting() {
         final var modification = tree.takeSnapshot().newModification();
         // We write node without creating parent
-        modification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+        modification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
             .build());
         modification.ready();
         try {
@@ -49,7 +51,8 @@ class ErrorReportingTest extends AbstractTestModelTest {
     void parentConcurrentlyDeletedExisting() throws DataValidationFailedException {
         final var initial = tree.takeSnapshot().newModification();
         // We write node without creating parent
-        initial.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        initial.write(TestModel.TEST_PATH,
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build());
         initial.ready();
         // We commit transaction
         tree.commit(tree.prepare(initial));
@@ -61,7 +64,9 @@ class ErrorReportingTest extends AbstractTestModelTest {
         // We commit delete modification
         tree.commit(tree.prepare(deleteTx));
 
-        writeTx.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        writeTx.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+            .build());
         writeTx.ready();
         try {
             tree.validate(writeTx);
index 99b850951a5e7f8e9c613cc6cb10d14c3104e38e..c2ee6118fc997f3c759e9f2047c5614ab1c3337c 100644 (file)
@@ -29,8 +29,7 @@ import org.opendaylight.yangtools.yang.data.api.YangNetconfErrorAware;
 import org.opendaylight.yangtools.yang.data.api.schema.DistinctNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
@@ -129,7 +128,9 @@ class ListConstraintsValidation {
         final var initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
         final var modificationTree = initialDataTreeSnapshot.newModification();
 
-        modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.containerNode(MASTER_CONTAINER_QNAME));
+        modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MASTER_CONTAINER_QNAME))
+            .build());
         modificationTree.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(modificationTree));
     }
@@ -139,10 +140,10 @@ class ListConstraintsValidation {
 
         final var fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo");
         final var barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar");
-        final var mapNode1 = ImmutableNodes.mapNodeBuilder()
+        final var mapNode1 = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
                 .withChild(fooEntryNode).build();
-        final var mapNode2 = ImmutableNodes.mapNodeBuilder()
+        final var mapNode2 = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
                 .withChild(barEntryNode).build();
 
@@ -172,7 +173,7 @@ class ListConstraintsValidation {
                     "bar");
             final var gooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
                     "goo");
-            final var mapNode = ImmutableNodes.mapNodeBuilder()
+            final var mapNode = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
                 .withChild(fooEntryNode).build();
 
@@ -225,18 +226,12 @@ class ListConstraintsValidation {
         final var barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar");
         final var gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo");
 
-        modificationTree.write(MIN_MAX_LEAF_LIST_PATH, Builders.leafSetBuilder()
+        modificationTree.write(MIN_MAX_LEAF_LIST_PATH, ImmutableNodes.newSystemLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME))
             .withChildValue("foo")
             .build());
-        modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), Builders.<String>leafSetEntryBuilder()
-            .withNodeIdentifier(barPath)
-            .withValue("bar")
-            .build());
-        modificationTree.merge(MIN_MAX_LEAF_LIST_PATH.node(gooPath), Builders.<String>leafSetEntryBuilder()
-            .withNodeIdentifier(gooPath)
-            .withValue("goo")
-            .build());
+        modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), ImmutableNodes.leafSetEntry(barPath));
+        modificationTree.merge(MIN_MAX_LEAF_LIST_PATH.node(gooPath), ImmutableNodes.leafSetEntry(gooPath));
         modificationTree.delete(MIN_MAX_LEAF_LIST_PATH.node(gooPath));
         modificationTree.ready();
 
@@ -262,22 +257,13 @@ class ListConstraintsValidation {
         final var gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo");
         final var fuuPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "fuu");
 
-        modificationTree.write(MIN_MAX_LEAF_LIST_PATH, Builders.leafSetBuilder()
+        modificationTree.write(MIN_MAX_LEAF_LIST_PATH, ImmutableNodes.newSystemLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME))
             .withChildValue("foo")
             .build());
-        modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), Builders.<String>leafSetEntryBuilder()
-            .withNodeIdentifier(barPath)
-            .withValue("bar")
-            .build());
-        modificationTree.merge(MIN_MAX_LEAF_LIST_PATH.node(gooPath), Builders.<String>leafSetEntryBuilder()
-            .withNodeIdentifier(gooPath)
-            .withValue("goo")
-            .build());
-        modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(fuuPath), Builders.<String>leafSetEntryBuilder()
-            .withNodeIdentifier(fuuPath)
-            .withValue("fuu")
-            .build());
+        modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), ImmutableNodes.leafSetEntry(barPath));
+        modificationTree.merge(MIN_MAX_LEAF_LIST_PATH.node(gooPath), ImmutableNodes.leafSetEntry(gooPath));
+        modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(fuuPath), ImmutableNodes.leafSetEntry(fuuPath));
 
         final var ex = assertThrows(MinMaxElementsValidationFailedException.class,
             () -> modificationTree.ready());
@@ -291,15 +277,17 @@ class ListConstraintsValidation {
     void unkeyedListTestPass() throws DataValidationFailedException {
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
-        final var unkeyedListNode = Builders.unkeyedListBuilder()
+        final var unkeyedListNode = ImmutableNodes.newUnkeyedListBuilder()
             .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
-            .withValue(List.of(Builders.unkeyedListEntryBuilder()
+            .withValue(List.of(ImmutableNodes.newUnkeyedListEntryBuilder()
                 .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME))
                 .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo"))
                 .build()))
             .build();
 
-        modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.containerNode(MASTER_CONTAINER_QNAME));
+        modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MASTER_CONTAINER_QNAME))
+            .build());
         modificationTree.merge(UNKEYED_LIST_PATH, unkeyedListNode);
         modificationTree.ready();
 
@@ -317,14 +305,14 @@ class ListConstraintsValidation {
     void unkeyedListTestFail() {
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
-        modificationTree.write(UNKEYED_LIST_PATH, Builders.unkeyedListBuilder()
+        modificationTree.write(UNKEYED_LIST_PATH, ImmutableNodes.newUnkeyedListBuilder()
             .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
             .withValue(List.of(
-                Builders.unkeyedListEntryBuilder()
+                ImmutableNodes.newUnkeyedListEntryBuilder()
                     .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME))
                     .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo"))
                     .build(),
-                Builders.unkeyedListEntryBuilder()
+                ImmutableNodes.newUnkeyedListEntryBuilder()
                     .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME))
                     .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "bar"))
                     .build()))
index 3d2c52bcd9ca0d00da246faa1056b58a9b3c96e9..802ced6adcb570797a3705405300fd46daa9f96b 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
 
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
@@ -17,7 +16,7 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
@@ -49,14 +48,15 @@ class MandatoryLeafTest {
         final var inMemoryDataTree = initDataTree(true);
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
-        final var container = Builders.containerBuilder()
+        final var container = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(choice1Id)
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                    .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
-                    .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                    .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
+                    .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"),
+                        "leaf-value2"))
                     .build())
                 .build())
             .build();
@@ -74,7 +74,7 @@ class MandatoryLeafTest {
     void testCorrectMandatoryLeafChoiceWrite() throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree(true);
         // Container write
-        final var container = Builders.containerBuilder()
+        final var container = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
             .build();
 
@@ -88,12 +88,12 @@ class MandatoryLeafTest {
 
         // Choice write
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
-        final var choice = Builders.choiceBuilder()
+        final var choice = ImmutableNodes.newChoiceBuilder()
             .withNodeIdentifier(choice1Id)
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                 .build())
             .build();
 
@@ -112,13 +112,14 @@ class MandatoryLeafTest {
             final var inMemoryDataTree = initDataTree(true);
             final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
-            final var container = Builders.containerBuilder()
+            final var container = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(choice1Id)
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                        .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                        .withChild(ImmutableNodes.leafNode(
+                            QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                         .build())
                     .build())
                 .build();
@@ -145,13 +146,14 @@ class MandatoryLeafTest {
         final var inMemoryDataTree = initDataTree(false);
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
-        final ContainerNode container = Builders.containerBuilder()
+        final ContainerNode container = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(choice1Id)
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                    .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                    .withChild(ImmutableNodes.leafNode(
+                        QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                     .build())
                 .build())
             .build();
@@ -169,7 +171,7 @@ class MandatoryLeafTest {
         assertThrows(IllegalArgumentException.class, () -> {
             final var inMemoryDataTree = initDataTree(true);
             // Container write
-            final var container = Builders.containerBuilder()
+            final var container = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
             final var modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
@@ -182,11 +184,12 @@ class MandatoryLeafTest {
 
             // Choice write
             final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
-            final var choice = Builders.choiceBuilder()
+            final var choice = ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(choice1Id)
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                    .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                    .withChild(ImmutableNodes.leafNode(
+                        QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                     .build())
                 .build();
 
@@ -211,7 +214,7 @@ class MandatoryLeafTest {
     void testDisabledValidationChoiceWrite() throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree(false);
         // Container write
-        final var container = Builders.containerBuilder()
+        final var container = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
         final var modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
@@ -224,11 +227,11 @@ class MandatoryLeafTest {
 
         // Choice write
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
-        final var choice = Builders.choiceBuilder()
+        final var choice = ImmutableNodes.newChoiceBuilder()
             .withNodeIdentifier(choice1Id)
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                 .build())
             .build();
 
index 2692e5dd7ecf591b32ace846be8cf3c063bf3a55..5d7f076cc184db514a54516ea9e9fe5f97a860ab 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
@@ -23,8 +22,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
@@ -77,11 +75,11 @@ class ModificationMetadataTreeTest extends AbstractTestModelTest {
             .build();
 
     private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
-                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
-                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME,TestModel.NAME_QNAME, TWO_TWO_NAME))
-                    .build())
-                    .build();
+        .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
+            .withChild(ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
+            .withChild(ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME,TestModel.NAME_QNAME, TWO_TWO_NAME))
+            .build())
+        .build();
 
     private RootApplyStrategy rootOper;
 
@@ -109,17 +107,17 @@ class ModificationMetadataTreeTest extends AbstractTestModelTest {
      * @return a test document
      */
     public ContainerNode createDocumentOne() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
             .withChild(createTestContainer())
             .build();
     }
 
     private static ContainerNode createTestContainer() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
             .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
-                .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+                .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
                 .withChild(BAR_NODE).build())
             .build();
     }
@@ -170,10 +168,12 @@ class ModificationMetadataTreeTest extends AbstractTestModelTest {
 
         final var modificationTree = createEmptyModificationTree();
         // Writes empty container node to /test
-        modificationTree.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        modificationTree.write(TestModel.TEST_PATH,
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build());
 
         // Writes empty list node to /test/outer-list
-        modificationTree.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+        modificationTree.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
             .build());
 
         // Reads list node from /test/outer-list.
index bace335f3b8d673a8d02a64d791238855f5a193c..7d938ea2a325c60db9b9840a313c3a3e7cf53bcc 100644 (file)
@@ -8,10 +8,9 @@
 package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
-import com.google.common.collect.ImmutableMap;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -21,7 +20,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.ConflictingModificationAppliedException;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -104,26 +103,31 @@ class OrderedListTest {
     }
 
     public void modification1() throws DataValidationFailedException {
-        final var parentOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
-                new NodeIdentifier(parentOrderedList))
-                .withChild(createParentOrderedListEntry("pkval1", "plfval1"))
-                .withChild(createParentOrderedListEntry("pkval2", "plfval2"))
-                .withChild(createParentOrderedListEntry("pkval3", "plfval3")).build();
-
-        final var parentContainerNode = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode).build())
-                .build();
+        final var parentOrderedListNode = ImmutableNodes.newUserMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentOrderedList))
+            .withChild(createParentOrderedListEntry("pkval1", "plfval1"))
+            .withChild(createParentOrderedListEntry("pkval2", "plfval2"))
+            .withChild(createParentOrderedListEntry("pkval3", "plfval3"))
+            .build();
+
+        final var parentContainerNode = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentContainer))
+            .withChild(ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(childContainer))
+                .withChild(parentOrderedListNode)
+                .build())
+            .build();
 
         final var path1 = YangInstanceIdentifier.of(parentContainer);
 
         final var treeModification = inMemoryDataTree.takeSnapshot().newModification();
         treeModification.write(path1, parentContainerNode);
 
-        final var childOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
-                new NodeIdentifier(childOrderedList))
-                .withChild(createChildOrderedListEntry("chkval1", "chlfval1"))
-                .withChild(createChildOrderedListEntry("chkval2", "chlfval2")).build();
+        final var childOrderedListNode = ImmutableNodes.newUserMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(childOrderedList))
+            .withChild(createChildOrderedListEntry("chkval1", "chlfval1"))
+            .withChild(createChildOrderedListEntry("chkval2", "chlfval2"))
+            .build();
 
         final var path2 = YangInstanceIdentifier.of(parentContainer, childContainer, parentOrderedList)
             .node(createParentOrderedListEntryPath("pkval2")).node(childOrderedList);
@@ -142,27 +146,32 @@ class OrderedListTest {
     }
 
     public void modification2() throws DataValidationFailedException {
-        final var parentOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
-                new NodeIdentifier(parentOrderedList))
-                .withChild(createParentOrderedListEntry("pkval3", "plfval3updated"))
-                .withChild(createParentOrderedListEntry("pkval4", "plfval4"))
-                .withChild(createParentOrderedListEntry("pkval5", "plfval5")).build();
-
-        final var parentContainerNode = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode).build())
-                .build();
+        final var parentOrderedListNode = ImmutableNodes.newUserMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentOrderedList))
+            .withChild(createParentOrderedListEntry("pkval3", "plfval3updated"))
+            .withChild(createParentOrderedListEntry("pkval4", "plfval4"))
+            .withChild(createParentOrderedListEntry("pkval5", "plfval5"))
+            .build();
+
+        final var parentContainerNode = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentContainer))
+            .withChild(ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(childContainer))
+                .withChild(parentOrderedListNode)
+                .build())
+            .build();
 
         final var treeModification = inMemoryDataTree.takeSnapshot().newModification();
 
         final var path1 = YangInstanceIdentifier.of(parentContainer);
         treeModification.merge(path1, parentContainerNode);
 
-        final var childOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
-                new NodeIdentifier(childOrderedList))
-                .withChild(createChildOrderedListEntry("chkval1", "chlfval1updated"))
-                .withChild(createChildOrderedListEntry("chkval2", "chlfval2updated"))
-                .withChild(createChildOrderedListEntry("chkval3", "chlfval3")).build();
+        final var childOrderedListNode = ImmutableNodes.newUserMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(childOrderedList))
+            .withChild(createChildOrderedListEntry("chkval1", "chlfval1updated"))
+            .withChild(createChildOrderedListEntry("chkval2", "chlfval2updated"))
+            .withChild(createChildOrderedListEntry("chkval3", "chlfval3"))
+            .build();
 
         final var path2 = YangInstanceIdentifier.of(parentContainer).node(childContainer)
                 .node(parentOrderedList).node(createParentOrderedListEntryPath("pkval2")).node(childOrderedList);
@@ -181,23 +190,28 @@ class OrderedListTest {
     }
 
     public void modification3() throws DataValidationFailedException {
-        final var parentOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
-                new NodeIdentifier(parentOrderedList))
-                .withChild(createParentOrderedListEntry("pkval1", "plfval1")).build();
-
-        final var parentContainerNode = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode).build())
-                .build();
+        final var parentOrderedListNode = ImmutableNodes.newUserMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentOrderedList))
+            .withChild(createParentOrderedListEntry("pkval1", "plfval1"))
+            .build();
+
+        final var parentContainerNode = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentContainer))
+            .withChild(ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(childContainer))
+                .withChild(parentOrderedListNode)
+                .build())
+            .build();
 
         final var path1 = YangInstanceIdentifier.of(parentContainer);
 
         final var treeModification = inMemoryDataTree.takeSnapshot().newModification();
         treeModification.write(path1, parentContainerNode);
 
-        final var childOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
-                new NodeIdentifier(childOrderedList))
-                .withChild(createChildOrderedListEntry("chkval1", "chlfval1new")).build();
+        final var childOrderedListNode = ImmutableNodes.newUserMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(childOrderedList))
+            .withChild(createChildOrderedListEntry("chkval1", "chlfval1new"))
+            .build();
 
         final var path2 = YangInstanceIdentifier.of(parentContainer).node(childContainer)
                 .node(parentOrderedList)
@@ -205,15 +219,8 @@ class OrderedListTest {
 
         treeModification.merge(path2, childOrderedListNode);
 
-        try {
-            treeModification.ready();
-            fail("Exception should have been thrown.");
-            inMemoryDataTree.validate(treeModification);
-            inMemoryDataTree.commit(inMemoryDataTree.prepare(treeModification));
-        } catch (final IllegalArgumentException ex) {
-            LOG.debug("IllegalArgumentException was thrown as expected", ex);
-            assertTrue(ex.getMessage().contains("Metadata not available for modification ModifiedNode"));
-        }
+        final var ex = assertThrows(IllegalArgumentException.class, treeModification::ready);
+        assertTrue(ex.getMessage().contains("Metadata not available for modification ModifiedNode"));
 
         final var snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         var readNode = snapshotAfterCommits.readNode(path1);
@@ -227,23 +234,31 @@ class OrderedListTest {
         final var treeModification1 = inMemoryDataTree.takeSnapshot().newModification();
         final var treeModification2 = inMemoryDataTree.takeSnapshot().newModification();
 
-        final var parentOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
-            new NodeIdentifier(parentOrderedList)).withChild(createParentOrderedListEntry("pkval1", "plfval1"))
-                .build();
-
-        final var parentOrderedListNode2 = Builders.orderedMapBuilder().withNodeIdentifier(
-            new NodeIdentifier(parentOrderedList)).withChild(createParentOrderedListEntry("pkval2", "plfval2"))
-                .build();
-
-        final var parentContainerNode = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode).build())
-                .build();
-
-        final var parentContainerNode2 = Builders.containerBuilder().withNodeIdentifier(
-                new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode2).build())
-                .build();
+        final var parentOrderedListNode = ImmutableNodes.newUserMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentOrderedList))
+            .withChild(createParentOrderedListEntry("pkval1", "plfval1"))
+            .build();
+
+        final var parentOrderedListNode2 = ImmutableNodes.newUserMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentOrderedList))
+            .withChild(createParentOrderedListEntry("pkval2", "plfval2"))
+            .build();
+
+        final var parentContainerNode = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentContainer))
+            .withChild(ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(childContainer))
+                .withChild(parentOrderedListNode)
+                .build())
+            .build();
+
+        final var parentContainerNode2 = ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(parentContainer))
+            .withChild(ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(childContainer))
+                .withChild(parentOrderedListNode2)
+                .build())
+            .build();
 
         final var path = YangInstanceIdentifier.of(parentContainer);
 
@@ -255,14 +270,10 @@ class OrderedListTest {
         inMemoryDataTree.validate(treeModification1);
         inMemoryDataTree.commit(inMemoryDataTree.prepare(treeModification1));
 
-        try {
-            inMemoryDataTree.validate(treeModification2);
-            fail("Exception should have been thrown.");
-            inMemoryDataTree.commit(inMemoryDataTree.prepare(treeModification2));
-        } catch (ConflictingModificationAppliedException ex) {
-            LOG.debug("ConflictingModificationAppliedException was thrown as expected", ex);
-            assertTrue(ex.getMessage().contains("Node was replaced by other transaction"));
-        }
+        final var ex = assertThrows(ConflictingModificationAppliedException.class,
+            () -> inMemoryDataTree.validate(treeModification2));
+        LOG.debug("ConflictingModificationAppliedException was thrown as expected", ex);
+        assertTrue(ex.getMessage().contains("Node was replaced by other transaction"));
 
         final var snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         final var readNode = snapshotAfterCommits.readNode(path);
@@ -301,28 +312,24 @@ class OrderedListTest {
     }
 
     private MapEntryNode createParentOrderedListEntry(final String keyValue, final String leafValue) {
-        return Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(parentOrderedList,
-                parentKeyLeaf, keyValue))
-                .withChild(Builders.leafBuilder().withNodeIdentifier(NodeIdentifier.create(parentOrdinaryLeaf))
-                    .withValue(leafValue).build()).build();
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(parentOrderedList, parentKeyLeaf, keyValue))
+            .withChild(ImmutableNodes.leafNode(parentOrdinaryLeaf, leafValue))
+            .build();
     }
 
     private MapEntryNode createChildOrderedListEntry(final String keyValue, final String leafValue) {
-        return Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(childOrderedList,
-                childKeyLeaf, keyValue))
-                .withChild(Builders.leafBuilder().withNodeIdentifier(NodeIdentifier.create(childOrdinaryLeaf))
-                    .withValue(leafValue).build()).build();
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(childOrderedList, childKeyLeaf, keyValue))
+            .withChild(ImmutableNodes.leafNode(childOrdinaryLeaf, leafValue))
+            .build();
     }
 
     private NodeIdentifierWithPredicates createParentOrderedListEntryPath(final String keyValue) {
-        ImmutableMap.Builder<QName, Object> builder = ImmutableMap.builder();
-        ImmutableMap<QName, Object> keys = builder.put(parentKeyLeaf, keyValue).build();
-        return NodeIdentifierWithPredicates.of(parentOrderedList, keys);
+        return NodeIdentifierWithPredicates.of(parentOrderedList, parentKeyLeaf, keyValue);
     }
 
     private NodeIdentifierWithPredicates createChildOrderedListEntryPath(final String keyValue) {
-        ImmutableMap.Builder<QName, Object> builder = ImmutableMap.builder();
-        ImmutableMap<QName, Object> keys = builder.put(childKeyLeaf, keyValue).build();
-        return NodeIdentifierWithPredicates.of(childOrderedList, keys);
+        return NodeIdentifierWithPredicates.of(childOrderedList, childKeyLeaf, keyValue);
     }
 }
index d65287b18f8edfacf91743598cfc82c3a31a72d8..b02b262999e70ed362826850c2b6f76d8a394aa6 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
@@ -24,7 +23,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.Version;
@@ -56,11 +55,11 @@ public class StoreTreeNodesTest extends AbstractTestModelTest {
             .build();
 
     private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
-                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
-                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME))
-                    .build())
-                    .build();
+        .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
+            .withChild(ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
+            .withChild(ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME))
+            .build())
+        .build();
 
     private RootApplyStrategy rootOper;
 
@@ -71,7 +70,7 @@ public class StoreTreeNodesTest extends AbstractTestModelTest {
     }
 
     public static ContainerNode createDocumentOne() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
             .withChild(createTestContainer())
             .build();
@@ -161,10 +160,10 @@ public class StoreTreeNodesTest extends AbstractTestModelTest {
     }
 
     private static ContainerNode createTestContainer() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
             .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
-                .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+                .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
                 .withChild(BAR_NODE)
                 .build())
             .build();
index 88f110e746d4252a6145b46ca38ff4ace75f2eaa..7be656f7d5045d3d460a11db501d9ec0be802e3c 100644 (file)
@@ -15,8 +15,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
@@ -38,13 +37,13 @@ final class StructuralApplyModificationTest extends AbstractTestModelTest {
         // Prepare root
         final var rootContainerId = getNId(TestModel.TEST_QNAME);
         addListEntryModification.write(YangInstanceIdentifier.of(rootContainerId),
-            Builders.containerBuilder().withNodeIdentifier(rootContainerId).build());
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(rootContainerId).build());
 
         final var outerListEntryId = NodeIdentifierWithPredicates.of(
             TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
 
         // Write list entry (MapEntryNode) without creating list parent (MapNode)
-        final var outerListEntry = Builders.mapEntryBuilder().withNodeIdentifier(outerListEntryId).build();
+        final var outerListEntry = ImmutableNodes.newMapEntryBuilder().withNodeIdentifier(outerListEntryId).build();
         final var outerListParentPath = YangInstanceIdentifier.of(getNId(TestModel.TEST_QNAME),
             getNId(TestModel.OUTER_LIST_QNAME));
         final var outerListEntryPath = outerListParentPath.node(outerListEntryId);
@@ -75,11 +74,13 @@ final class StructuralApplyModificationTest extends AbstractTestModelTest {
         // Prepare root container
         final var rootContainerId = getNId(TestModel.TEST_QNAME);
         addListEntryModification.write(YangInstanceIdentifier.of(rootContainerId),
-            Builders.containerBuilder().withNodeIdentifier(rootContainerId).build());
+            ImmutableNodes.newContainerBuilder().withNodeIdentifier(rootContainerId).build());
 
         final var outerListParentPath = YangInstanceIdentifier.of(getNId(TestModel.TEST_QNAME),
             getNId(TestModel.OUTER_LIST_QNAME));
-        addListEntryModification.merge(outerListParentPath, ImmutableNodes.mapNode(TestModel.OUTER_LIST_QNAME));
+        addListEntryModification.merge(outerListParentPath, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+            .build());
 
         // Check empty map node auto deleted
         assertNodeExistence(outerListParentPath, false);
@@ -91,7 +92,9 @@ final class StructuralApplyModificationTest extends AbstractTestModelTest {
 
         final var rootContainerId = getNId(TestModel.NON_PRESENCE_QNAME);
         final var path = YangInstanceIdentifier.of(rootContainerId);
-        addListEntryModification.write(path, Builders.containerBuilder().withNodeIdentifier(rootContainerId).build());
+        addListEntryModification.write(path, ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(rootContainerId)
+            .build());
 
         addListEntryModification.ready();
         inMemoryDataTree.validate(addListEntryModification);
@@ -109,7 +112,7 @@ final class StructuralApplyModificationTest extends AbstractTestModelTest {
             .node(getNId(TestModel.A_LIST_QNAME, TestModel.A_NAME_QNAME, "1"));
 
         addListEntryModification.write(path,
-            Builders.mapEntryBuilder()
+            ImmutableNodes.newMapEntryBuilder()
                 .withNodeIdentifier(getNId(TestModel.A_LIST_QNAME, TestModel.A_NAME_QNAME, "1"))
                 .build());
 
index 56cb5808336b0fd9f7e99ee0e3910d961f7d1e9d..048532b69f6971cb09d93b0ab543859d4bf2cff7 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangNetconfErrorAware;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
@@ -165,14 +164,13 @@ class UniqueConstraintTest {
 
     private static void writeMap(final InMemoryDataTree inMemoryDataTree, final boolean withUniqueViolation)
             throws DataValidationFailedException {
-        final var taskNode = Builders
-                .mapBuilder()
-                .withNodeIdentifier(new NodeIdentifier(TASK))
-                .withChild(createMapEntry("1", "l1", "l2", "l3"))
-                .withChild(createMapEntry("2", "l2", "l3", "l4"))
-                .withChild(
-                        withUniqueViolation ? createMapEntry("3", "l1", "l2", "l10") : createMapEntry("3", "l3", "l4",
-                                "l5")).build();
+        final var taskNode = ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TASK))
+            .withChild(createMapEntry("1", "l1", "l2", "l3"))
+            .withChild(createMapEntry("2", "l2", "l3", "l4"))
+            .withChild(
+                withUniqueViolation ? createMapEntry("3", "l1", "l2", "l10") : createMapEntry("3", "l3", "l4", "l5"))
+            .build();
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK), taskNode);
@@ -185,15 +183,16 @@ class UniqueConstraintTest {
     private static void writeMapEntry(final InMemoryDataTree inMemoryDataTree, final Object taskIdValue,
             final Object myLeaf1Value, final Object myLeaf2Value, final Object myLeaf3Value)
             throws DataValidationFailedException {
-        final var taskEntryNode = Builders
-                .mapEntryBuilder()
-                .withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, TASK_ID, taskIdValue))
-                .withChild(ImmutableNodes.leafNode(TASK_ID, taskIdValue))
-                .withChild(ImmutableNodes.leafNode(MY_LEAF_1, myLeaf1Value))
-                .withChild(ImmutableNodes.leafNode(MY_LEAF_2, myLeaf2Value))
-                .withChild(
-                        Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(MY_CONTAINER))
-                                .withChild(ImmutableNodes.leafNode(MY_LEAF_3, myLeaf3Value)).build()).build();
+        final var taskEntryNode = ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, TASK_ID, taskIdValue))
+            .withChild(ImmutableNodes.leafNode(TASK_ID, taskIdValue))
+            .withChild(ImmutableNodes.leafNode(MY_LEAF_1, myLeaf1Value))
+            .withChild(ImmutableNodes.leafNode(MY_LEAF_2, myLeaf2Value))
+            .withChild(ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(MY_CONTAINER))
+                .withChild(ImmutableNodes.leafNode(MY_LEAF_3, myLeaf3Value))
+                .build())
+            .build();
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(
@@ -218,15 +217,16 @@ class UniqueConstraintTest {
 
     private static MapEntryNode createMapEntry(final Object taskIdValue, final Object myLeaf1Value,
             final Object myLeaf2Value, final Object myLeaf3Value) {
-        return Builders
-                .mapEntryBuilder()
-                .withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, TASK_ID, taskIdValue))
-                .withChild(ImmutableNodes.leafNode(TASK_ID, taskIdValue))
-                .withChild(ImmutableNodes.leafNode(MY_LEAF_1, myLeaf1Value))
-                .withChild(ImmutableNodes.leafNode(MY_LEAF_2, myLeaf2Value))
-                .withChild(
-                        Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(MY_CONTAINER))
-                                .withChild(ImmutableNodes.leafNode(MY_LEAF_3, myLeaf3Value)).build()).build();
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, TASK_ID, taskIdValue))
+            .withChild(ImmutableNodes.leafNode(TASK_ID, taskIdValue))
+            .withChild(ImmutableNodes.leafNode(MY_LEAF_1, myLeaf1Value))
+            .withChild(ImmutableNodes.leafNode(MY_LEAF_2, myLeaf2Value))
+            .withChild(ImmutableNodes.newContainerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(MY_CONTAINER))
+                .withChild(ImmutableNodes.leafNode(MY_LEAF_3, myLeaf3Value))
+                .build())
+            .build();
     }
 
     private static NodeIdentifierWithPredicates taskEntryKey(final String taskId) {
@@ -257,7 +257,7 @@ class UniqueConstraintTest {
             new DataTreeConfiguration.Builder(TreeType.CONFIGURATION).setUniqueIndexes(uniqueIndex).build());
         inMemoryDataTree.setEffectiveModelContext(schemaContext);
 
-        final var taskNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(TASK)).build();
+        final var taskNode = ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(TASK)).build();
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK), taskNode);
         modificationTree.ready();
index 1c4bb214f9f255f817b9062b10ec52f4d9c38c79..102d9abb9b5c514b0199c735cd60f4dc1a1a80fb 100644 (file)
@@ -7,10 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.data.tree.impl;
 
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.anyXmlBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.anydataBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
-
 import javax.xml.transform.dom.DOMSource;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
@@ -20,6 +16,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
@@ -64,17 +61,24 @@ class YT1104Test {
 
     @Test
     void testAnydata() throws DataValidationFailedException {
-        writeChoice(anydataBuilder(String.class).withNodeIdentifier(BAR).withValue("anydata").build());
+        writeChoice(ImmutableNodes.newAnydataBuilder(String.class)
+            .withNodeIdentifier(BAR)
+            .withValue("anydata")
+            .build());
     }
 
     @Test
     void testAnyxml() throws DataValidationFailedException {
-        writeChoice(anyXmlBuilder().withNodeIdentifier(BAZ).withValue(new DOMSource()).build());
+        writeChoice(ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
+            .withNodeIdentifier(BAZ)
+            .withValue(new DOMSource())
+            .build());
     }
 
     private void writeChoice(final DataContainerChild child) throws DataValidationFailedException {
         final var mod = dataTree.takeSnapshot().newModification();
-        mod.write(YangInstanceIdentifier.of(FOO), choiceBuilder().withNodeIdentifier(FOO).withChild(child).build());
+        mod.write(YangInstanceIdentifier.of(FOO),
+            ImmutableNodes.newChoiceBuilder().withNodeIdentifier(FOO).withChild(child).build());
         mod.ready();
         dataTree.validate(mod);
         dataTree.commit(dataTree.prepare(mod));
index 214984310581399b8d89f40bf0f07b5626ca4737..bb303bcf1935fd4308dec938572f0ac11ebde79e 100644 (file)
@@ -16,7 +16,6 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -54,7 +53,7 @@ class YT1276Test {
     @Test
     void testFooWithBar() throws DataValidationFailedException {
         applyOperation(mod -> {
-            mod.write(YangInstanceIdentifier.of(FOO), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(FOO), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(FOO))
                 .withChild(ImmutableNodes.leafNode(BAR, "xyzzy"))
                 .build());
@@ -65,7 +64,7 @@ class YT1276Test {
     @Deprecated
     void testFooWithBarLegacy() throws DataValidationFailedException {
         applyOperation(mod -> {
-            mod.write(YangInstanceIdentifier.of(FOO), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(FOO), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(FOO))
                 .withChild(ImmutableNodes.leafNode(BAR, "xyzzy"))
                 .build());
@@ -75,7 +74,7 @@ class YT1276Test {
     @Test
     void testFooWithoutBar() {
         final IllegalArgumentException ex = assertFailsReady(mod -> {
-            mod.write(YangInstanceIdentifier.of(FOO), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(FOO), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(FOO))
                 .build());
         });
@@ -85,15 +84,15 @@ class YT1276Test {
     @Test
     void testBarWithXyzzyWithSubtree() throws DataValidationFailedException {
         applyOperation(mod -> {
-            mod.write(YangInstanceIdentifier.of(BAR), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(BAR), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(BAR))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAZ))
                     .withChild(ImmutableNodes.leafNode(XYZZY_LEAF, "xyzzy"))
                     .withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT, "xyzzy"))
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(new NodeIdentifier(XYZZY_AUGMENT_CONT))
-                        .withChild(Builders.containerBuilder()
+                        .withChild(ImmutableNodes.newContainerBuilder()
                             .withNodeIdentifier(new NodeIdentifier(XYZZY_AUGMENT_CONT_INNER))
                             .withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT_CONT_LEAF, "aug-cont-leaf"))
                             .build())
@@ -106,9 +105,9 @@ class YT1276Test {
     @Test
     void testBazWithAugmentedCaseWithMandatoryLeaf() throws DataValidationFailedException {
         applyOperation(mod -> {
-            mod.write(YangInstanceIdentifier.of(BAR), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(BAR), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(BAR))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAZ))
                     .withChild(ImmutableNodes.leafNode(BAZ_AUG_CASE_MANDAT_LEAF, "augmentedCaseMandatory"))
                     .withChild(ImmutableNodes.leafNode(BAZ_AUG_CASE_NON_MANDAT_LEAF, "augmentedCaseNonMandatory"))
@@ -121,9 +120,9 @@ class YT1276Test {
     void testBazWithAugmentedCaseWithoutMandatoryLeaf() throws DataValidationFailedException {
         assertThrows(IllegalArgumentException.class, () -> {
             applyOperation(mod -> {
-                mod.write(YangInstanceIdentifier.of(BAR), Builders.containerBuilder()
+                mod.write(YangInstanceIdentifier.of(BAR), ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAR))
-                    .withChild(Builders.choiceBuilder()
+                    .withChild(ImmutableNodes.newChoiceBuilder()
                         .withNodeIdentifier(new NodeIdentifier(BAZ))
                         .withChild(ImmutableNodes.leafNode(BAZ_AUG_CASE_NON_MANDAT_LEAF, "augmentedCaseNonMandatory"))
                         .build())
@@ -135,11 +134,11 @@ class YT1276Test {
     @Test
     void testWithAugmentedNestedBazWithMandatoryLeaf() throws DataValidationFailedException {
         applyOperation(mod -> {
-            mod.write(YangInstanceIdentifier.of(BAR), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(BAR), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(BAR))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAZ))
-                    .withChild(Builders.choiceBuilder()
+                    .withChild(ImmutableNodes.newChoiceBuilder()
                         .withNodeIdentifier(new NodeIdentifier(NESTED_BAZ_CHOICE))
                         .withChild(ImmutableNodes.leafNode(NESTED_BAZ_XYZ_CASE_MANDATORY, "nestedMandatory"))
                         .withChild(ImmutableNodes.leafNode(NESTED_BAZ_XYZ_CASE_NON_MANDATORY, "nestedNonMandatory"))
@@ -153,11 +152,11 @@ class YT1276Test {
     void testWithAugmentedNestedBazWithhoutMandatoryLeaf() throws DataValidationFailedException {
         assertThrows(IllegalArgumentException.class, () -> {
             applyOperation(mod -> {
-                mod.write(YangInstanceIdentifier.of(BAR), Builders.containerBuilder()
+                mod.write(YangInstanceIdentifier.of(BAR), ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAR))
-                    .withChild(Builders.choiceBuilder()
+                    .withChild(ImmutableNodes.newChoiceBuilder()
                         .withNodeIdentifier(new NodeIdentifier(BAZ))
-                        .withChild(Builders.choiceBuilder()
+                        .withChild(ImmutableNodes.newChoiceBuilder()
                             .withNodeIdentifier(new NodeIdentifier(NESTED_BAZ_CHOICE))
                             .withChild(ImmutableNodes.leafNode(NESTED_BAZ_XYZ_CASE_NON_MANDATORY, "nestedNonMandatory"))
                             .build())
@@ -171,15 +170,15 @@ class YT1276Test {
     @Deprecated
     void testBarWithXyzzyLegacy() throws DataValidationFailedException {
         applyOperation(mod -> {
-            mod.write(YangInstanceIdentifier.of(BAR), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(BAR), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(BAR))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAZ))
                     .withChild(ImmutableNodes.leafNode(XYZZY_LEAF, "xyzzy"))
                     .withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT, "xyzzy"))
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(NodeIdentifier.create(XYZZY_AUGMENT_CONT))
-                        .withChild(Builders.containerBuilder()
+                        .withChild(ImmutableNodes.newContainerBuilder()
                             .withNodeIdentifier(NodeIdentifier.create(XYZZY_AUGMENT_CONT_INNER))
                             .withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT_CONT_LEAF, "aug-cont-leaf"))
                             .build())
@@ -192,14 +191,14 @@ class YT1276Test {
     @Test
     void testBarWithoutXyzzyLeaf() {
         final var ex = assertFailsReady(mod -> {
-            mod.write(YangInstanceIdentifier.of(BAR), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(BAR), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(BAR))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAZ))
                     .withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT, "xyzzy"))
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(NodeIdentifier.create(XYZZY_AUGMENT_CONT))
-                        .withChild(Builders.containerBuilder()
+                        .withChild(ImmutableNodes.newContainerBuilder()
                             .withNodeIdentifier(NodeIdentifier.create(XYZZY_AUGMENT_CONT_INNER))
                             .withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT_CONT_LEAF, "aug-cont-leaf"))
                             .build())
@@ -215,9 +214,9 @@ class YT1276Test {
     @Test
     void testBarWithoutXyzzyAugment() {
         final var ex = assertFailsReady(mod -> {
-            mod.write(YangInstanceIdentifier.of(BAR), Builders.containerBuilder()
+            mod.write(YangInstanceIdentifier.of(BAR), ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(BAR))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAZ))
                     .withChild(ImmutableNodes.leafNode(XYZZY_LEAF, "xyzzy"))
                     .build())
index 781728f66a2facb486ce03cdf4ed009f0da82617..5784e28da4f88a9d960124696e8f5d9ea5c9fa3b 100644 (file)
@@ -9,14 +9,6 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafSetBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.mapBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.tree.impl.ListConstraintsValidation.assertTooFewElements;
-import static org.opendaylight.yangtools.yang.data.tree.impl.ListConstraintsValidation.assertTooManyElements;
 
 import com.google.common.collect.ImmutableMap;
 import org.junit.jupiter.api.AfterAll;
@@ -29,6 +21,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
@@ -45,8 +38,7 @@ class YT776Test {
     private static final NodeIdentifier OBJECT_LIST = new NodeIdentifier(OBJECT);
     private static final NodeIdentifierWithPredicates OBJECT_ITEM = NodeIdentifierWithPredicates.of(OBJECT,
         ImmutableMap.of(OBJECT_ID, "1"));
-    private static final LeafNode<?> OBJECT_ID_LEAF = leafBuilder().withNodeIdentifier(new NodeIdentifier(OBJECT_ID))
-            .withValue("1").build();
+    private static final LeafNode<?> OBJECT_ID_LEAF = ImmutableNodes.leafNode(OBJECT_ID, "1");
     private static final NodeIdentifier ATTRIBUTES = new NodeIdentifier(QName.create(MODULE, "attributes"));
 
     private static final QName NESTED = QName.create(MODULE, "nested");
@@ -126,15 +118,18 @@ class YT776Test {
     @Test
     void testNoAttributes() {
         final var mod = dataTree.takeSnapshot().newModification();
-        mod.write(YangInstanceIdentifier.of(BOX), containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        mod.write(YangInstanceIdentifier.of(BOX), ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
                     .build())
                 .build())
             .build());
 
-        final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, mod::ready);
+        final var ex = assertThrows(IllegalArgumentException.class, mod::ready);
         // FIXME: This is actually mandatory leaf enforcer kicking in: attributes have to be present. This is
         //        most probably not what we want.
         assertEquals("Node (yt776)object[{(yt776)object-id=1}] is missing mandatory descendant /(yt776)attributes",
@@ -143,27 +138,34 @@ class YT776Test {
 
     @Test
     void testEmptyAttributes() throws DataValidationFailedException {
-        final var mod = write(containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        final var mod = write(ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
-                    .withChild(leafSetBuilder().withNodeIdentifier(ATTRIBUTES).build())
+                    .withChild(ImmutableNodes.newSystemLeafSetBuilder().withNodeIdentifier(ATTRIBUTES).build())
                     .build())
                 .build())
             .build());
 
         final var ex = assertThrows(MinMaxElementsValidationFailedException.class, mod::ready);
         assertEquals("(yt776)attributes does not have enough elements (0), needs at least 1", ex.getMessage());
-        assertTooFewElements(ex);
+        ListConstraintsValidation.assertTooFewElements(ex);
     }
 
     @Test
     void testOneAttribute() throws DataValidationFailedException {
-        writeAndCommit(containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        writeAndCommit(ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
-                    .withChild(leafSetBuilder().withNodeIdentifier(ATTRIBUTES)
+                    .withChild(ImmutableNodes.newSystemLeafSetBuilder()
+                        .withNodeIdentifier(ATTRIBUTES)
                         .withChildValue("object1")
                         .build())
                     .build())
@@ -173,11 +175,15 @@ class YT776Test {
 
     @Test
     void testTwoAttributes() throws DataValidationFailedException {
-        writeAndCommit(containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        writeAndCommit(ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
-                    .withChild(leafSetBuilder().withNodeIdentifier(ATTRIBUTES)
+                    .withChild(ImmutableNodes.newSystemLeafSetBuilder()
+                        .withNodeIdentifier(ATTRIBUTES)
                         .withChildValue("object1")
                         .withChildValue("object2")
                         .build())
@@ -188,11 +194,15 @@ class YT776Test {
 
     @Test
     void testThreeAttributes() throws DataValidationFailedException {
-        final var mod = write(containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        final var mod = write(ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
-                    .withChild(leafSetBuilder().withNodeIdentifier(ATTRIBUTES)
+                    .withChild(ImmutableNodes.newSystemLeafSetBuilder()
+                        .withNodeIdentifier(ATTRIBUTES)
                         .withChildValue("object1")
                         .withChildValue("object2")
                         .withChildValue("object3")
@@ -203,24 +213,31 @@ class YT776Test {
 
         final var ex = assertThrows(MinMaxElementsValidationFailedException.class, mod::ready);
         assertEquals("(yt776)attributes has too many elements (3), can have at most 2", ex.getMessage());
-        assertTooManyElements(ex);
+        ListConstraintsValidation.assertTooManyElements(ex);
     }
 
     @Test
     void testEmptyAndMergeOne() throws DataValidationFailedException {
         final var mod = dataTree.takeSnapshot().newModification();
-        mod.write(YangInstanceIdentifier.of(BOX), containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        mod.write(YangInstanceIdentifier.of(BOX), ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
                     .build())
                 .build())
             .build());
-        mod.merge(YangInstanceIdentifier.of(BOX), containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        mod.merge(YangInstanceIdentifier.of(BOX), ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
-                    .withChild(leafSetBuilder().withNodeIdentifier(ATTRIBUTES)
+                    .withChild(ImmutableNodes.newSystemLeafSetBuilder()
+                        .withNodeIdentifier(ATTRIBUTES)
                         .withChildValue("object1")
                         .build())
                     .build())
@@ -233,18 +250,25 @@ class YT776Test {
     @Test
     void testEmptyAndMergeOneWithListTouched() throws DataValidationFailedException {
         final var mod = dataTree.takeSnapshot().newModification();
-        mod.write(YangInstanceIdentifier.of(BOX), containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        mod.write(YangInstanceIdentifier.of(BOX), ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
                     .build())
                 .build())
             .build());
-        mod.merge(YangInstanceIdentifier.of(BOX), containerBuilder().withNodeIdentifier(BOX)
-            .withChild(mapBuilder().withNodeIdentifier(OBJECT_LIST)
-                .addChild(mapEntryBuilder().withNodeIdentifier(OBJECT_ITEM)
+        mod.merge(YangInstanceIdentifier.of(BOX), ImmutableNodes.newContainerBuilder()
+            .withNodeIdentifier(BOX)
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(OBJECT_LIST)
+                .addChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(OBJECT_ITEM)
                     .withChild(OBJECT_ID_LEAF)
-                    .withChild(leafSetBuilder().withNodeIdentifier(ATTRIBUTES)
+                    .withChild(ImmutableNodes.newSystemLeafSetBuilder()
+                        .withNodeIdentifier(ATTRIBUTES)
                         .withChildValue("object1")
                         .build())
                     .build())
@@ -260,13 +284,15 @@ class YT776Test {
     void testDisappearInChoice() throws DataValidationFailedException {
         var mod = dataTree.takeSnapshot().newModification();
         // Initialize choice with list
-        mod.write(YangInstanceIdentifier.of(BOX), containerBuilder()
+        mod.write(YangInstanceIdentifier.of(BOX), ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(BOX)
-            .withChild(choiceBuilder().withNodeIdentifier(ANY_OF)
-                .withChild(mapBuilder().withNodeIdentifier(SOME_LIST_ID)
-                    .withChild(mapEntryBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
+                .withNodeIdentifier(ANY_OF)
+                .withChild(ImmutableNodes.newSystemMapBuilder()
+                    .withNodeIdentifier(SOME_LIST_ID)
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(SOME_LIST_ITEM)
-                        .withChild(leafBuilder().withNodeIdentifier(SOME_LEAF_ID).withValue("foo").build())
+                        .withChild(ImmutableNodes.leafNode(SOME_LEAF_ID, "foo"))
                         .build())
                     .build())
                 .build())
@@ -276,8 +302,7 @@ class YT776Test {
         // Now delete the single item, causing the list to fizzle, while creating the alterinative case
         mod = dataTree.takeSnapshot().newModification();
         mod.delete(YangInstanceIdentifier.of(BOX, ANY_OF, SOME_LIST_ID, SOME_LIST_ITEM));
-        mod.write(YangInstanceIdentifier.of(BOX, ANY_OF, SOME_LEAF_ID),
-            leafBuilder().withNodeIdentifier(SOME_LEAF_ID).withValue("foo").build());
+        mod.write(YangInstanceIdentifier.of(BOX, ANY_OF, SOME_LEAF_ID), ImmutableNodes.leafNode(SOME_LEAF_ID, "foo"));
 
         commit(mod);
     }
index 5b7b24cef196b9897400bd1629fe6605c68ceda9..0207932e2710f29868a6f73bf4684198a0ec5e47 100644 (file)
@@ -12,7 +12,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
@@ -69,7 +68,7 @@ class Bug8713Test {
     }
 
     private static ContainerNode createRootContainer() {
-        return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(foo("root")))
+        return ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(foo("root")))
                 .withChild(ImmutableNodes.leafNode(bar("target"), "target value"))
                 .withChild(ImmutableNodes.leafNode(bar("ref"), "target value")).build();
     }
index e357736dfb68d25eea8fc51c6d15027054f2e96d..2f12b0cdc3799b91b0cf23079bd3e09bfe593a06 100644 (file)
@@ -20,14 +20,11 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -295,7 +292,7 @@ public class DataTreeCandidateValidatorTest {
 
     private static void write2() throws DataValidationFailedException {
         final var writeModification = inMemoryDataTree.takeSnapshot().newModification();
-        writeModification.write(YangInstanceIdentifier.of(odl).node(con1), Builders.containerBuilder()
+        writeModification.write(YangInstanceIdentifier.of(odl).node(con1), ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(con1))
             .addChild(ImmutableNodes.leafNode(l1, "l1 value"))
             .build());
@@ -324,20 +321,20 @@ public class DataTreeCandidateValidatorTest {
     }
 
     private static @NonNull LeafSetNode<Object> createLeafRefLeafListNode() {
-        return Builders.leafSetBuilder()
+        return ImmutableNodes.newSystemLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(leafrefLeafList))
-            .addChild(createLeafSetEntry(leafrefLeafList, "k1"))
-            .addChild(createLeafSetEntry(leafrefLeafList, "k2"))
-            .addChild(createLeafSetEntry(leafrefLeafList, "k3"))
+            .addChild(ImmutableNodes.leafSetEntry(leafrefLeafList, "k1"))
+            .addChild(ImmutableNodes.leafSetEntry(leafrefLeafList, "k2"))
+            .addChild(ImmutableNodes.leafSetEntry(leafrefLeafList, "k3"))
             .build();
     }
 
     private static ContainerNode createCon3Node() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(con3))
-            .addChild(Builders.choiceBuilder()
+            .addChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(new NodeIdentifier(choiceInCon3))
-                .addChild(Builders.mapBuilder()
+                .addChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(list3InChoice))
                     .addChild(createList3Entry("k1", "val1", "valA", "valX"))
                     .addChild(createList3Entry("k2", "val2", "valB", "valY"))
@@ -348,31 +345,24 @@ public class DataTreeCandidateValidatorTest {
 
     private static MapEntryNode createList3Entry(final String keyVal,final String l3Val1, final String l3Val2,
             final String l3Val3) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(list3InChoice, k, keyVal))
             .addChild(ImmutableNodes.leafNode(k, keyVal))
-            .addChild(Builders.leafSetBuilder()
+            .addChild(ImmutableNodes.newSystemLeafSetBuilder()
                 .withNodeIdentifier(new NodeIdentifier(l3))
-                .addChild(createLeafSetEntry(l3, l3Val1))
-                .addChild(createLeafSetEntry(l3, l3Val2))
-                .addChild(createLeafSetEntry(l3, l3Val3))
+                .addChild(ImmutableNodes.leafSetEntry(l3, l3Val1))
+                .addChild(ImmutableNodes.leafSetEntry(l3, l3Val2))
+                .addChild(ImmutableNodes.leafSetEntry(l3, l3Val3))
                 .build())
             .build();
     }
 
-    private static LeafSetEntryNode<Object> createLeafSetEntry(final QName qname, final String val) {
-        return Builders.leafSetEntryBuilder()
-            .withNodeIdentifier(new NodeWithValue<>(qname, val))
-            .withValue(val)
-            .build();
-    }
-
     private static ChoiceNode createChoiceNode() {
-        return Builders.choiceBuilder()
+        return ImmutableNodes.newChoiceBuilder()
             .withNodeIdentifier(new NodeIdentifier(ch1))
-            .addChild(Builders.choiceBuilder()
+            .addChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ch2))
-                .addChild(Builders.mapBuilder()
+                .addChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(listInChoice))
                     .addChild(createListInChoiceEntry("key1", "leafref-in-choice value", "val1"))
                     .addChild(createListInChoiceEntry("key2", "l1 value", "val2"))
@@ -384,7 +374,7 @@ public class DataTreeCandidateValidatorTest {
 
     private static MapEntryNode createListInChoiceEntry(final String keyVal, final String leafrefInChoiceVal,
             final String leafrefInChoiceToChoiceVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(listInChoice, listInChoiceKey, keyVal))
             .addChild(ImmutableNodes.leafNode(listInChoiceKey, keyVal))
             .addChild(ImmutableNodes.leafNode(leafrefInChoice, leafrefInChoiceVal))
@@ -418,7 +408,7 @@ public class DataTreeCandidateValidatorTest {
     }
 
     private static ContainerNode createContributorContainer(final ContainerSchemaNode contributorCont) {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(odlContributor))
             .addChild(createContributorList((ListSchemaNode) contributorCont.getDataChildByName(contributor)))
             .build();
@@ -426,7 +416,7 @@ public class DataTreeCandidateValidatorTest {
     }
 
     private static SystemMapNode createContributorList(final ListSchemaNode contributorListSchemaNode) {
-        return Builders.mapBuilder()
+        return ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(contributor))
             .addChild(createContributorListEntry("Leader of Yangtools", "Yangtools Leader name", "Yangtools",
                 "Yangtools description ..."))
@@ -445,7 +435,7 @@ public class DataTreeCandidateValidatorTest {
 
     private static MapEntryNode createContributorListEntry(final String loginVal, final String contributorNameVal,
             final String odlProjectNameVal, final String odlProjectDescVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(contributor, login, loginVal))
             .addChild(ImmutableNodes.leafNode(login, loginVal))
             .addChild(ImmutableNodes.leafNode(contributorName, contributorNameVal))
@@ -455,14 +445,14 @@ public class DataTreeCandidateValidatorTest {
     }
 
     private static ContainerNode createOdlContainer() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(odl))
             .addChild(createProjectList())
             .build();
     }
 
     private static SystemMapNode createProjectList() {
-        return Builders.mapBuilder()
+        return ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(project))
             .addChild(createProjectListEntry("Yangtools", "Yangtools description ...", "Leader of Yangtools",
                 "Owner of Yangtools"))
@@ -473,7 +463,7 @@ public class DataTreeCandidateValidatorTest {
 
     private static MapEntryNode createProjectListEntry(final String nameVal, final String descVal, final String leadVal,
             final String ownerVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(project, name, nameVal))
             .addChild(ImmutableNodes.leafNode(name, nameVal))
             .addChild(ImmutableNodes.leafNode(desc, descVal))
@@ -483,14 +473,14 @@ public class DataTreeCandidateValidatorTest {
     }
 
     private static ContainerNode createBasicContributorContainer() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(odlContributor))
             .addChild(createBasicContributorList())
             .build();
     }
 
     private static SystemMapNode createBasicContributorList() {
-        return Builders.mapBuilder()
+        return ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(contributor))
             .addChild(createContributorListEntry("Leader of Yangtools", "Yangtools Leader name", "Yangtools",
                 "Yangtools description ..."))
index a371ddf12862a530e70998cf47ed24f637dc5c0f..9f0686f41e5849ff5d5201f7f29a614c76e6212b 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -91,18 +90,18 @@ public class DataTreeCandidateValidatorTest2 {
 
         inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
-        initialDataTreeModification.write(YangInstanceIdentifier.of(chips), Builders.containerBuilder()
+        initialDataTreeModification.write(YangInstanceIdentifier.of(chips), ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(chips))
-            .addChild(Builders.mapBuilder()
+            .addChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(chip))
                 .addChild(createChipsListEntry("dev_type_1", "desc1"))
                 .addChild(createChipsListEntry("dev_type_2", "desc2"))
                 .build())
             .build());
 
-        initialDataTreeModification.write(YangInstanceIdentifier.of(deviceTypeStr), Builders.containerBuilder()
+        initialDataTreeModification.write(YangInstanceIdentifier.of(deviceTypeStr), ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(deviceTypeStr))
-            .addChild(Builders.mapBuilder()
+            .addChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(deviceType))
                 .addChild(createDevTypeListEntry("dev_type_1", "typedesc1"))
                 .addChild(createDevTypeListEntry("dev_type_2", "typedesc2"))
@@ -132,9 +131,9 @@ public class DataTreeCandidateValidatorTest2 {
 
     private static void writeDevices() throws DataValidationFailedException {
         final var writeModification = inMemoryDataTree.takeSnapshot().newModification();
-        writeModification.write(YangInstanceIdentifier.of(devices), Builders.containerBuilder()
+        writeModification.write(YangInstanceIdentifier.of(devices), ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(devices))
-            .addChild(Builders.mapBuilder()
+            .addChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(device))
                 .addChild(createDeviceListEntry("dev_type_1", "typedesc1", 123456, "192.168.0.1"))
                 .addChild(createDeviceListEntry("dev_type_2", "typedesc2", 123457, "192.168.0.1"))
@@ -165,7 +164,7 @@ public class DataTreeCandidateValidatorTest2 {
     }
 
     private static MapEntryNode createDevTypeListEntry(final String typeVal, final String descVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(deviceType, type, typeVal))
             .addChild(ImmutableNodes.leafNode(type, typeVal))
             .addChild(ImmutableNodes.leafNode(desc, descVal))
@@ -173,7 +172,7 @@ public class DataTreeCandidateValidatorTest2 {
     }
 
     private static MapEntryNode createChipsListEntry(final String devTypeVal, final String chipDescVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(chip, devType, devTypeVal))
             .addChild(ImmutableNodes.leafNode(devType, devTypeVal))
             .addChild(ImmutableNodes.leafNode(chipDesc, chipDescVal))
@@ -182,7 +181,7 @@ public class DataTreeCandidateValidatorTest2 {
 
     private static MapEntryNode createDeviceListEntry(final String typeTextVal, final String descVal, final int snVal,
             final String defaultIpVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(device, Map.of(typeText, typeTextVal, sn, snVal)))
             .addChild(ImmutableNodes.leafNode(typeText, typeTextVal))
             .addChild(ImmutableNodes.leafNode(devDesc, descVal))
index 85922a582afaa39a78df1260a00d092861846c61..843e85afb62753cad44f41681788fc2dfd450d0b 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -103,18 +102,18 @@ public class DataTreeCandidateValidatorTest3 {
 
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
 
-        initialDataTreeModification.write(YangInstanceIdentifier.of(chips), Builders.containerBuilder()
+        initialDataTreeModification.write(YangInstanceIdentifier.of(chips), ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(chips))
-            .addChild(Builders.mapBuilder()
+            .addChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(chip))
                 .addChild(createChipsListEntry("dev_type_1", "desc1"))
                 .addChild(createChipsListEntry("dev_type_2", "desc2"))
                 .build())
             .build());
 
-        initialDataTreeModification.write(YangInstanceIdentifier.of(deviceTypeStr), Builders.containerBuilder()
+        initialDataTreeModification.write(YangInstanceIdentifier.of(deviceTypeStr), ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(deviceTypeStr))
-            .addChild(Builders.mapBuilder()
+            .addChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(deviceType))
                 .addChild(createDevTypeListEntry("dev_type1_1", "dev_type2_1", "dev_type3_1", "typedesc1"))
                 .addChild(createDevTypeListEntry("dev_type1_2", "dev_type2_2", "dev_type3_2", "typedesc2"))
@@ -146,9 +145,9 @@ public class DataTreeCandidateValidatorTest3 {
 
     private static void writeDevices() throws DataValidationFailedException {
         final var writeModification = inMemoryDataTree.takeSnapshot().newModification();
-        writeModification.write(YangInstanceIdentifier.of(devices), Builders.containerBuilder()
+        writeModification.write(YangInstanceIdentifier.of(devices), ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(devices))
-            .addChild(Builders.mapBuilder()
+            .addChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(device))
                 .addChild(createDeviceListEntry("dev_type1_1", "dev_type2_1", "dev_type3_1", "typedesc1", 123456,
                     "192.168.0.1"))
@@ -181,9 +180,9 @@ public class DataTreeCandidateValidatorTest3 {
     }
 
     private static void mergeDevices() throws DataValidationFailedException {
-        final var devicesContainer = Builders.containerBuilder()
+        final var devicesContainer = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(devices))
-            .addChild(Builders.mapBuilder()
+            .addChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(device))
                 .addChild(createDeviceListEntry("dev_type1_3", "dev_type2_3", "dev_type3_3", "typedesc3", 123459,
                     "192.168.0.1"))
@@ -223,7 +222,7 @@ public class DataTreeCandidateValidatorTest3 {
 
     private static MapEntryNode createDevTypeListEntry(final String type1Val, final String type2Val,
             final String type3Val, final String descVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(deviceType,
                 Map.of(type1, type1Val, type2, type2Val, type3, type3Val)))
             .addChild(ImmutableNodes.leafNode(type1, type1Val))
@@ -234,7 +233,7 @@ public class DataTreeCandidateValidatorTest3 {
     }
 
     private static MapEntryNode createChipsListEntry(final String devTypeVal, final String chipDescVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(chip, devType, devTypeVal))
             .addChild(ImmutableNodes.leafNode(devType, devTypeVal))
             .addChild(ImmutableNodes.leafNode(chipDesc, chipDescVal))
@@ -243,7 +242,7 @@ public class DataTreeCandidateValidatorTest3 {
 
     private static MapEntryNode createDeviceListEntry(final String type1TextVal, final String type2TextVal,
             final String type3TextVal, final String descVal, final int snVal, final String defaultIpVal) {
-        return Builders.mapEntryBuilder()
+        return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(device, Map.of(typeText1, type1TextVal, sn, snVal)))
             .addChild(ImmutableNodes.leafNode(typeText1, type1TextVal))
             .addChild(ImmutableNodes.leafNode(typeText2, type2TextVal))
index 0605799a68d7a669639a5e85e8526784029d2039..9c1d8f661ef9bbf8caf02ab8f2e786502da7b378 100644 (file)
@@ -18,7 +18,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -148,21 +147,21 @@ class YT821Test {
     }
 
     private static ContainerNode refFromAug(final String refValue) {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(FOO))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, NAME, "foo1"))
                         .withChild(ImmutableNodes.leafNode(NAME, "foo1"))
                         .build())
                     .build())
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAR))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(BAR, NAME, "bar1"))
                         .withChild(ImmutableNodes.leafNode(NAME, "bar1"))
-                        .withChild(Builders.containerBuilder()
+                        .withChild(ImmutableNodes.newContainerBuilder()
                             .withNodeIdentifier(new NodeIdentifier(CONTAINER_IN_LIST))
                             .withChild(ImmutableNodes.leafNode(REF_FROM_AUG, refValue))
                             .build())
@@ -172,21 +171,21 @@ class YT821Test {
     }
 
     private static ContainerNode refInContainer(final String refValue) {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(FOO))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, NAME, "foo1"))
                         .withChild(ImmutableNodes.leafNode(NAME, "foo1"))
                         .build())
                     .build())
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(BAR))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(BAR, NAME, "bar1"))
                         .withChild(ImmutableNodes.leafNode(NAME, "bar1"))
-                        .withChild(Builders.containerBuilder()
+                        .withChild(ImmutableNodes.newContainerBuilder()
                             .withNodeIdentifier(new NodeIdentifier(CONTAINER_FROM_AUG))
                             .withChild(ImmutableNodes.leafNode(REF_IN_CONTAINER, refValue))
                             .build())
index eda885a59c92747158effd11bb8ad954529758f1..86ad6154044c60c842054c95a4c7cc3fec558a80 100644 (file)
@@ -18,7 +18,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -165,14 +164,14 @@ class YT891Test {
     }
 
     private static ContainerNode fooTopWithList(final String refValue) {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(FOO_TOP))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(LIST_IN_GROUPING))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_IN_GROUPING, NAME, "name1"))
                         .withChild(ImmutableNodes.leafNode(NAME, "name1"))
-                        .withChild(Builders.containerBuilder()
+                        .withChild(ImmutableNodes.newContainerBuilder()
                             .withNodeIdentifier(new NodeIdentifier(CONTAINER_IN_LIST))
                             .withChild(ImmutableNodes.leafNode(NAME, refValue))
                             .build())
@@ -182,18 +181,18 @@ class YT891Test {
     }
 
     private static ContainerNode fooTopWithRef(final String refValue) {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(FOO_TOP))
                 .withChild(ImmutableNodes.leafNode(REF, refValue))
                 .build();
     }
 
     private static ContainerNode bazTop() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(BAZ_TOP))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(LIST_IN_CONTAINER))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_IN_CONTAINER, BAZ_NAME, "name1"))
                         .withChild(ImmutableNodes.leafNode(BAZ_NAME, "name1"))
                         .build())
index 6cfc6acbd27c6e130585905510291bf8de5f9379..296210516790cb7f43147243f400a9c97859aeaa 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.yangtools.yang.common.Uint8;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
@@ -70,13 +69,13 @@ class YT892Test {
     @Test
     void testWriteBgpNeighbour() throws Exception {
         final var writeModification = dataTree.takeSnapshot().newModification();
-        writeModification.write(BGP_ID, Builders.containerBuilder()
+        writeModification.write(BGP_ID, ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(BGP))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(PEER_GROUPS))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(PEER_GROUP))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(PEER_GROUP,
                             PEER_GROUP_NAME, "application-peers"))
                         .withChild(ImmutableNodes.leafNode(PEER_GROUP_NAME, "application-peers"))
@@ -85,58 +84,58 @@ class YT892Test {
                 .build())
             .build());
 
-        writeModification.write(NETWORK_INSTANCES_ID, Builders.containerBuilder()
+        writeModification.write(NETWORK_INSTANCES_ID, ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(NETWORK_INSTANCES))
-            .withChild(Builders.mapBuilder()
+            .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(NETWORK_INSTANCE))
-                .withChild(Builders.mapEntryBuilder()
+                .withChild(ImmutableNodes.newMapEntryBuilder()
                     .withNodeIdentifier(NodeIdentifierWithPredicates.of(NETWORK_INSTANCE, NAME, "global-bgp"))
                     .withChild(ImmutableNodes.leafNode(NAME, "global-bgp"))
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(new NodeIdentifier(CONFIG))
                         .withChild(ImmutableNodes.leafNode(NAME, "global-bgp"))
                         .build())
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(new NodeIdentifier(PROTOCOLS))
-                        .withChild(Builders.mapBuilder()
+                        .withChild(ImmutableNodes.newSystemMapBuilder()
                             .withNodeIdentifier(new NodeIdentifier(PROTOCOL))
-                            .withChild(Builders.mapEntryBuilder()
+                            .withChild(ImmutableNodes.newMapEntryBuilder()
                                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(PROTOCOL, ImmutableMap.of(
                                     IDENTIFIER, BGP_POLICY,
                                     NAME, "test-bgp-instance")))
                                 .withChild(ImmutableNodes.leafNode(IDENTIFIER, BGP_POLICY))
                                 .withChild(ImmutableNodes.leafNode(NAME, "test-bgp-instance"))
-                                .withChild(Builders.containerBuilder()
+                                .withChild(ImmutableNodes.newContainerBuilder()
                                     .withNodeIdentifier(new NodeIdentifier(CONFIG))
                                     .withChild(ImmutableNodes.leafNode(IDENTIFIER, BGP_POLICY))
                                     .withChild(ImmutableNodes.leafNode(NAME, "test-bgp-instance"))
                                     .build())
-                                .withChild(Builders.containerBuilder()
+                                .withChild(ImmutableNodes.newContainerBuilder()
                                     .withNodeIdentifier(new NodeIdentifier(TEST_BGP))
-                                    .withChild(Builders.containerBuilder()
+                                    .withChild(ImmutableNodes.newContainerBuilder()
                                         .withNodeIdentifier(new NodeIdentifier(NEIGHBORS))
-                                        .withChild(Builders.mapBuilder()
+                                        .withChild(ImmutableNodes.newSystemMapBuilder()
                                             .withNodeIdentifier(new NodeIdentifier(NEIGHBOR))
-                                            .withChild(Builders.mapEntryBuilder()
+                                            .withChild(ImmutableNodes.newMapEntryBuilder()
                                                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(NEIGHBOR,
                                                     NEIGHBOR_ADDRESS, "10.25.1.9"))
                                                 .withChild(ImmutableNodes.leafNode(NEIGHBOR_ADDRESS, "10.25.1.9"))
-                                                .withChild(Builders.containerBuilder()
+                                                .withChild(ImmutableNodes.newContainerBuilder()
                                                     .withNodeIdentifier(new NodeIdentifier(TEST_CONFIG))
                                                     .withChild(ImmutableNodes.leafNode(TEST_PEER_GROUP,
                                                         "application-peers"))
                                                     .build())
-                                                .withChild(Builders.containerBuilder()
+                                                .withChild(ImmutableNodes.newContainerBuilder()
                                                     .withNodeIdentifier(new NodeIdentifier(AFI_SAFIS))
-                                                    .withChild(Builders.mapBuilder()
+                                                    .withChild(ImmutableNodes.newSystemMapBuilder()
                                                         .withNodeIdentifier(new NodeIdentifier(AFI_SAFI))
-                                                        .withChild(Builders.mapEntryBuilder()
+                                                        .withChild(ImmutableNodes.newMapEntryBuilder()
                                                             .withNodeIdentifier(NodeIdentifierWithPredicates.of(
                                                                 AFI_SAFI,
                                                                 ImmutableMap.of(AFI_SAFI_NAME, IPV4_UNICAST)))
                                                             .withChild(ImmutableNodes.leafNode(AFI_SAFI_NAME,
                                                                 IPV4_UNICAST))
-                                                            .withChild(Builders.containerBuilder()
+                                                            .withChild(ImmutableNodes.newContainerBuilder()
                                                                 .withNodeIdentifier(
                                                                     new NodeIdentifier(TEST_CONFIG))
                                                                 .withChild(ImmutableNodes.leafNode(