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;
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
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);
}
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());
</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>
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 {
}
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"));
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;
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);
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())
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())
@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) {
*/
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;
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(
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();
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());
}
}
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();
}
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;
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;
}
}
- private static final BuilderFactory BUILDER_FACTORY = ImmutableNodes.builderFactory();
-
private final @NonNull JSONInstanceIdentifierCodec iidCodec;
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
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)) {
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();
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;
}
}""");
- 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());
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;
}
}
}""");
- 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();
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;
@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())
@Test
void parseData() throws Exception {
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(FOO))
.withChild(ImmutableNodes.leafNode(STR, "str"))
.build(),
}"""));
assertEquals(List.of(), prefixAndNode.prefix());
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(FOO))
.withChild(ImmutableNodes.leafNode(STR, "str"))
.build(), prefixAndNode.result().data());
]
}"""));
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"))
}
}"""));
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"))
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(),
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(),
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("""
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("""
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;
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())
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;
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 =
}
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() {
}
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() {
}
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() {
}
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() {
}
public static ContainerNode emptyContainerInContainer() {
- return cont1Node(Builders.containerBuilder()
+ return cont1Node(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(COMPLEX_JSON, "cont11")))
.build());
}
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;
]
}
}""")));
- 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"))
// Annotations
requires static org.eclipse.jdt.annotation;
+ requires org.opendaylight.yangtools.yang.data.spi;
}
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 {
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())
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,
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;
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());
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())
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();
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;
}
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())
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;
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())
}
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();
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;
}
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"))
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;
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())
@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";
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())
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 {
}
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())
// .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"))
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;
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;
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;
}
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;
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())
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;
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"?>
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"?>
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;
<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"))
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;
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());
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;
@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);
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;
}
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"))
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;
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;
@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)
.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
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();
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"))
.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(),
* 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:
* @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())
@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())
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())
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())
@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())
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;
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() {
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);
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);
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"))
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;
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);
}
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();
+ }
}
@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();
@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));
@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)
@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)
@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();
*/
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;
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(
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");
* @return A test node
*/
protected static ContainerNode createContainerNode() {
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
.withChild(createMapNode())
.withChild(createChoiceNode())
}
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())
}
protected static ChoiceNode createChoiceNode() {
- return Builders.choiceBuilder()
+ return ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(NodeIdentifier.create(CHOICE_QNAME))
.withChild(createAugmentedLeafNode())
.build();
}
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())
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();
}
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();
}
}
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;
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();
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;
// 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));
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;
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"))
/* 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"))
}
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) {
}
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
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;
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();
"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();
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));
}
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();
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);
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();
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;
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();
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"))
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"))
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"))
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"))
}
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) {
}
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"))
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;
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();
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();
}
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"))
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))
}
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();
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();
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
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;
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);
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();
}
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"))
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))
}
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();
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();
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;
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);
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();
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;
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();
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();
@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());
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.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;
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();
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);
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();
// 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();
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;
}
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();
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();
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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
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();
+ }
}
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;
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;
.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)
.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();
}
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);
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);
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;
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();
@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);
@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);
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);
// 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);
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;
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 {
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));
// 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);
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;
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));
}
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();
"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();
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();
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());
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();
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()))
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;
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;
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();
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();
// 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();
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();
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();
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();
// 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();
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();
// 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();
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;
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;
.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;
* @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();
}
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.
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;
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;
}
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);
}
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);
}
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)
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);
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);
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);
}
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);
}
}
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;
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;
.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;
}
public static 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();
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;
// 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);
// 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);
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);
.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());
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;
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);
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(
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) {
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();
*/
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;
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;
@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));
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;
@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());
@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());
@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());
});
@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())
@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"))
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())
@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"))
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())
@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())
@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())
@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())
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;
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;
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");
@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",
@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())
@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())
@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")
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())
@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())
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())
// 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);
}
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;
}
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();
}
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;
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());
}
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"))
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"))
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))
}
private static ContainerNode createContributorContainer(final ContainerSchemaNode contributorCont) {
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(odlContributor))
.addChild(createContributorList((ListSchemaNode) contributorCont.getDataChildByName(contributor)))
.build();
}
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 ..."))
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))
}
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"))
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))
}
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 ..."))
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;
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"))
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"))
}
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))
}
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))
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))
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;
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"))
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"))
}
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"))
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))
}
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))
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))
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;
}
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())
}
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())
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;
}
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())
}
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())
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;
@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"))
.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(