From: Robert Varga Date: Fri, 12 Feb 2016 13:12:20 +0000 (+0100) Subject: NoddeWithValue is generic X-Git-Tag: release/boron~221 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=7d94cf9582dad0ed87050bb4fee0dde5bd52d1c7;p=yangtools.git NoddeWithValue is generic This fixes warnings with use of the raw type. Also cleans up references to YangInstanceIdentifier inner classes. Change-Id: If2f88f14e14c9b0b858187ba99a491af485e19d2 Signed-off-by: Robert Varga --- diff --git a/yang/yang-data-api/src/test/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifierTest.java b/yang/yang-data-api/src/test/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifierTest.java index d4a0abb530..0f1483444f 100644 --- a/yang/yang-data-api/src/test/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifierTest.java +++ b/yang/yang-data-api/src/test/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifierTest.java @@ -273,29 +273,29 @@ public class YangInstanceIdentifierTest { @Test public void testNodeWithValue() { - NodeWithValue node1 = new NodeWithValue( NODENAME1, "foo" ); + NodeWithValue node1 = new NodeWithValue<>( NODENAME1, "foo" ); assertEquals( "getNodeType", NODENAME1, node1.getNodeType() ); assertEquals( "getValue", "foo", node1.getValue() ); - NodeWithValue node2 = new NodeWithValue( NODENAME1, "foo" ); + NodeWithValue node2 = new NodeWithValue<>( NODENAME1, "foo" ); assertEquals( "hashCode", node1.hashCode(), node2.hashCode() ); assertEquals( "equals", true, node1.equals( node2 ) ); - assertEquals( "equals", false, node1.equals( new NodeWithValue( NODENAME1, "bar" ) ) ); - assertEquals( "equals", false, node1.equals( new NodeWithValue( NODENAME2, "foo" ) ) ); + assertEquals( "equals", false, node1.equals( new NodeWithValue<>( NODENAME1, "bar" ) ) ); + assertEquals( "equals", false, node1.equals( new NodeWithValue<>( NODENAME2, "foo" ) ) ); assertEquals( "equals", false, node1.equals( new Object() ) ); assertNotNull( node1.toString() ); // for code coverage assertNotNull( node1.toRelativeString(node2) ); - NodeWithValue node3 = new NodeWithValue( NODENAME1, new byte[]{1,2} ); - NodeWithValue node4 = new NodeWithValue( NODENAME1, new byte[]{1,2} ); + NodeWithValue node3 = new NodeWithValue<>( NODENAME1, new byte[]{1,2} ); + NodeWithValue node4 = new NodeWithValue<>( NODENAME1, new byte[]{1,2} ); assertEquals( "hashCode", node3.hashCode(), node4.hashCode() ); assertEquals( "equals", true, node3.equals( node4 ) ); - assertEquals( "equals", false, node3.equals( new NodeWithValue( NODENAME1, new byte[]{1,3} ) ) ); + assertEquals( "equals", false, node3.equals( new NodeWithValue<>( NODENAME1, new byte[]{1,3} ) ) ); assertEquals( "equals", false, node3.equals( node1 ) ); } diff --git a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java index 79011b131c..0001a05aad 100644 --- a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java +++ b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java @@ -37,8 +37,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuil public class TestingNormalizedNodeStructuresCreator { + @SafeVarargs static NormalizedNode cont1Node( - DataContainerChild... children) { + final DataContainerChild... children) { DataContainerNodeAttrBuilder cont1 = Builders.containerBuilder(); cont1.withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "cont1"))); @@ -105,8 +106,9 @@ public class TestingNormalizedNodeStructuresCreator { .withValue("lf15_11 value from augmentation").build(); } + @SafeVarargs private static DataContainerChild choc11Node( - DataContainerChild... children) { + final DataContainerChild... children) { DataContainerNodeBuilder choc11Builder = Builders.choiceBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "choc11"))); choc11Builder.withValue(Lists.newArrayList(children)); @@ -206,7 +208,7 @@ public class TestingNormalizedNodeStructuresCreator { return YangInstanceIdentifier.create( new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "cont1")), new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "lflst11")), - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"),"foo") + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"),"foo") ); } @@ -216,12 +218,12 @@ public class TestingNormalizedNodeStructuresCreator { lflst11.withChild(Builders .leafSetEntryBuilder() .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1")) + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1")) .withValue("lflst11 value1").build()); lflst11.withChild(Builders .leafSetEntryBuilder() .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2")) + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2")) .withValue("lflst11 value2").build()); return lflst11.build(); } @@ -232,12 +234,12 @@ public class TestingNormalizedNodeStructuresCreator { lflst11.withChild(Builders .leafSetEntryBuilder() .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1\nanother line 1")) + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1\nanother line 1")) .withValue("lflst11 value1\nanother line 1").build()); lflst11.withChild(Builders .leafSetEntryBuilder() .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2\r\nanother line 2")) + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2\r\nanother line 2")) .withValue("lflst11 value2\r\nanother line 2").build()); return lflst11.build(); } diff --git a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/Bug4969Test.java b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/Bug4969Test.java index 1f704e56d6..babd4fb51f 100644 --- a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/Bug4969Test.java +++ b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/Bug4969Test.java @@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.codec.gson.retest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import com.google.common.base.Optional; import com.google.gson.stream.JsonReader; import java.io.File; @@ -55,7 +54,7 @@ public class Bug4969Test { verifyNormalizedNodeResult(context); } - private void verifyNormalizedNodeResult(SchemaContext context) throws IOException, URISyntaxException { + private static void verifyNormalizedNodeResult(final SchemaContext context) throws IOException, URISyntaxException { final String inputJson = TestUtils.loadTextFile("/bug-4969/json/foo.json"); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); @@ -123,7 +122,7 @@ public class Bug4969Test { parseJsonToNormalizedNodes(context); } - private void parseJsonToNormalizedNodes(SchemaContext context) throws IOException, URISyntaxException { + private static void parseJsonToNormalizedNodes(final SchemaContext context) throws IOException, URISyntaxException { final String inputJson = TestUtils.loadTextFile("/leafref/json/data.json"); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); diff --git a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/TestingNormalizedNodeStructuresCreator.java b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/TestingNormalizedNodeStructuresCreator.java index d2fa87808b..52f7bd7a84 100644 --- a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/TestingNormalizedNodeStructuresCreator.java +++ b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/TestingNormalizedNodeStructuresCreator.java @@ -9,10 +9,8 @@ package org.opendaylight.yangtools.yang.data.codec.gson.retest; import com.google.common.collect.Lists; import com.google.common.collect.Sets; - import java.util.HashMap; import java.util.Map; - import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; @@ -39,8 +37,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuil public class TestingNormalizedNodeStructuresCreator { + @SafeVarargs static NormalizedNode cont1Node( - DataContainerChild... children) { + final DataContainerChild... children) { DataContainerNodeAttrBuilder cont1 = Builders.containerBuilder(); cont1.withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "cont1"))); @@ -107,8 +106,9 @@ public class TestingNormalizedNodeStructuresCreator { .withValue("lf15_11 value from augmentation").build(); } + @SafeVarargs private static DataContainerChild choc11Node( - DataContainerChild... children) { + final DataContainerChild... children) { DataContainerNodeBuilder choc11Builder = Builders.choiceBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "choc11"))); choc11Builder.withValue(Lists.newArrayList(children)); @@ -208,7 +208,7 @@ public class TestingNormalizedNodeStructuresCreator { return YangInstanceIdentifier.create( new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "cont1")), new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "lflst11")), - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"),"foo") + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"),"foo") ); } @@ -218,12 +218,12 @@ public class TestingNormalizedNodeStructuresCreator { lflst11.withChild(Builders .leafSetEntryBuilder() .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1")) + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1")) .withValue("lflst11 value1").build()); lflst11.withChild(Builders .leafSetEntryBuilder() .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2")) + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2")) .withValue("lflst11 value2").build()); return lflst11.build(); } @@ -234,12 +234,12 @@ public class TestingNormalizedNodeStructuresCreator { lflst11.withChild(Builders .leafSetEntryBuilder() .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1\nanother line 1")) + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1\nanother line 1")) .withValue("lflst11 value1\nanother line 1").build()); lflst11.withChild(Builders .leafSetEntryBuilder() .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2\r\nanother line 2")) + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2\r\nanother line 2")) .withValue("lflst11 value2\r\nanother line 2").build()); return lflst11.build(); } diff --git a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/YangModeledAnyXmlSupportTest.java b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/YangModeledAnyXmlSupportTest.java index a9baac8dec..220bb7193b 100644 --- a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/YangModeledAnyXmlSupportTest.java +++ b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/retest/YangModeledAnyXmlSupportTest.java @@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.codec.gson.retest; import static org.junit.Assert.assertEquals; import static org.opendaylight.yangtools.yang.data.codec.gson.retest.TestUtils.loadModules; import static org.opendaylight.yangtools.yang.data.codec.gson.retest.TestUtils.loadTextFile; - import com.google.common.base.Preconditions; import com.google.gson.JsonElement; import com.google.gson.JsonParser; @@ -106,7 +105,7 @@ public class YangModeledAnyXmlSupportTest { assertEquals(expextedJson, serializedJson); } - private String normalizedNodeToJsonStreamTransformation(final Writer writer, + private static String normalizedNodeToJsonStreamTransformation(final Writer writer, final NormalizedNode inputStructure) throws IOException { final NormalizedNodeStreamWriter jsonStream = JSONNormalizedNodeStreamWriter.createExclusiveWriter( diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/retest/XmlUtils.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/retest/XmlUtils.java index 55aa667252..c2d8ba3d52 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/retest/XmlUtils.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/retest/XmlUtils.java @@ -73,7 +73,7 @@ public final class XmlUtils { } } else if (pathArgument instanceof NodeWithValue) { textContent.append("[.='"); - textContent.append(((NodeWithValue) pathArgument).getValue()); + textContent.append(((NodeWithValue) pathArgument).getValue()); textContent.append("']"); } } diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToSimpleNodes.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToSimpleNodes.java index ab62d4cc28..e5d91fb3c8 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToSimpleNodes.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToSimpleNodes.java @@ -14,6 +14,9 @@ import java.util.Map; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.ModifyAction; 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.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; 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; @@ -24,7 +27,7 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; /** * Base strategy for converting an instance identifier into a normalized node structure for leaf and leaf-list types. */ -abstract class InstanceIdToSimpleNodes extends InstanceIdToNodes { +abstract class InstanceIdToSimpleNodes extends InstanceIdToNodes { protected InstanceIdToSimpleNodes(final T identifier) { super(identifier); @@ -33,8 +36,8 @@ abstract class InstanceIdToSimpleNodes create(final YangInstanceIdentifier instanceId, final Optional> deepestChild, final Optional> operation) { checkNotNull(instanceId); - final YangInstanceIdentifier.PathArgument pathArgument = instanceId.getPathArguments().get(0); - final NormalizedNodeAttrBuilder> builder = getBuilder(pathArgument); + final PathArgument pathArgument = instanceId.getPathArguments().get(0); + final NormalizedNodeAttrBuilder> builder = getBuilder(pathArgument); if(deepestChild.isPresent()) { builder.withValue(deepestChild.get().getValue()); @@ -44,21 +47,21 @@ abstract class InstanceIdToSimpleNodes> getBuilder(YangInstanceIdentifier.PathArgument node); + protected abstract NormalizedNodeAttrBuilder> getBuilder(PathArgument node); @Override - public InstanceIdToNodes getChild(final YangInstanceIdentifier.PathArgument child) { + public InstanceIdToNodes getChild(final PathArgument child) { return null; } - static final class LeafNormalization extends InstanceIdToSimpleNodes { + static final class LeafNormalization extends InstanceIdToSimpleNodes { protected LeafNormalization(final LeafSchemaNode potential) { - super(new YangInstanceIdentifier.NodeIdentifier(potential.getQName())); + super(new NodeIdentifier(potential.getQName())); } @Override - protected NormalizedNodeAttrBuilder> getBuilder(final YangInstanceIdentifier.PathArgument node) { + protected NormalizedNodeAttrBuilder> getBuilder(final PathArgument node) { return Builders.leafBuilder().withNodeIdentifier(getIdentifier()); } @@ -68,16 +71,16 @@ abstract class InstanceIdToSimpleNodes { + static final class LeafListEntryNormalization extends InstanceIdToSimpleNodes { public LeafListEntryNormalization(final LeafListSchemaNode potential) { - super(new YangInstanceIdentifier.NodeWithValue(potential.getQName(), null)); + super(new YangInstanceIdentifier.NodeWithValue<>(potential.getQName(), null)); } @Override - protected NormalizedNodeAttrBuilder> getBuilder(final YangInstanceIdentifier.PathArgument node) { + protected NormalizedNodeAttrBuilder> getBuilder(final YangInstanceIdentifier.PathArgument node) { Preconditions.checkArgument(node instanceof YangInstanceIdentifier.NodeWithValue); - return Builders.leafSetEntryBuilder().withNodeIdentifier((YangInstanceIdentifier.NodeWithValue) node).withValue(((YangInstanceIdentifier.NodeWithValue) node).getValue()); + return Builders.leafSetEntryBuilder().withNodeIdentifier((YangInstanceIdentifier.NodeWithValue) node).withValue(((YangInstanceIdentifier.NodeWithValue) node).getValue()); } @Override diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetEntryNodeSchemaAwareBuilder.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetEntryNodeSchemaAwareBuilder.java index ee81f907c7..248ee28411 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetEntryNodeSchemaAwareBuilder.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetEntryNodeSchemaAwareBuilder.java @@ -27,7 +27,7 @@ public final class ImmutableLeafSetEntryNodeSchemaAwareBuilder extends Immuta @Override public NormalizedNodeAttrBuilder> withValue(final T value) { - super.withNodeIdentifier(new NodeWithValue(schema.getQName(), value)); + super.withNodeIdentifier(new NodeWithValue<>(schema.getQName(), value)); // TODO check value type using TypeProvider ? return super.withValue(value); } diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetNodeBuilder.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetNodeBuilder.java index 2c5e3ba596..943c789751 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetNodeBuilder.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetNodeBuilder.java @@ -100,7 +100,7 @@ public class ImmutableLeafSetNodeBuilder implements ListNodeBuilder> withChildValue(final T value, final Map attributes) { final ImmutableLeafSetEntryNodeBuilder b = ImmutableLeafSetEntryNodeBuilder.create(); - b.withNodeIdentifier(new NodeWithValue(nodeIdentifier.getNodeType(), value)); + b.withNodeIdentifier(new NodeWithValue<>(nodeIdentifier.getNodeType(), value)); b.withValue(value); b.withAttributes(attributes); return withChild(b.build()); diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedLeafSetNodeBuilder.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedLeafSetNodeBuilder.java index 67eb342fab..059741d6a0 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedLeafSetNodeBuilder.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedLeafSetNodeBuilder.java @@ -16,8 +16,8 @@ import java.util.Map; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.util.UnmodifiableCollection; 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.NodeWithValue; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; @@ -28,8 +28,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableN public class ImmutableOrderedLeafSetNodeBuilder implements ListNodeBuilder> { - private Map> value; - private YangInstanceIdentifier.NodeIdentifier nodeIdentifier; + private Map> value; + private NodeIdentifier nodeIdentifier; private boolean dirty; protected ImmutableOrderedLeafSetNodeBuilder() { @@ -83,8 +83,7 @@ public class ImmutableOrderedLeafSetNodeBuilder implements ListNodeBuilder> withNodeIdentifier( - final YangInstanceIdentifier.NodeIdentifier nodeIdentifier) { + public ListNodeBuilder> withNodeIdentifier(final NodeIdentifier nodeIdentifier) { this.nodeIdentifier = nodeIdentifier; return this; } @@ -101,7 +100,7 @@ public class ImmutableOrderedLeafSetNodeBuilder implements ListNodeBuilder> withChildValue(final T value, final Map attributes) { final ImmutableLeafSetEntryNodeBuilder b = ImmutableLeafSetEntryNodeBuilder.create(); - b.withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue(nodeIdentifier.getNodeType(), value)); + b.withNodeIdentifier(new NodeWithValue<>(nodeIdentifier.getNodeType(), value)); b.withValue(value); b.withAttributes(attributes); return withChild(b.build()); @@ -113,19 +112,19 @@ public class ImmutableOrderedLeafSetNodeBuilder implements ListNodeBuilder extends - AbstractImmutableNormalizedNode>> implements + AbstractImmutableNormalizedNode>> implements Immutable, OrderedLeafSetNode { - private final Map> children; + private final Map> children; - ImmutableOrderedLeafSetNode(final YangInstanceIdentifier.NodeIdentifier nodeIdentifier, - final Map> children) { + ImmutableOrderedLeafSetNode(final NodeIdentifier nodeIdentifier, + final Map> children) { super(nodeIdentifier); this.children = children; } @Override - public Optional> getChild(final YangInstanceIdentifier.NodeWithValue child) { + public Optional> getChild(final NodeWithValue child) { return Optional.fromNullable(children.get(child)); } @@ -134,7 +133,7 @@ public class ImmutableOrderedLeafSetNodeBuilder implements ListNodeBuilder> getChildren() { + private Map> getChildren() { return Collections.unmodifiableMap(children); } diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractDataTreeCandidateNode.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractDataTreeCandidateNode.java index 10f12cf359..c02b6076e9 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractDataTreeCandidateNode.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractDataTreeCandidateNode.java @@ -13,7 +13,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Collections2; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/test/DataTreeCandidateValidatorTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/test/DataTreeCandidateValidatorTest.java index f723ecfaaa..2e13a4fe0e 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/test/DataTreeCandidateValidatorTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/test/DataTreeCandidateValidatorTest.java @@ -524,7 +524,7 @@ public class DataTreeCandidateValidatorTest { private static LeafSetEntryNode createLeafSetEntry(final QName qname, final String val) { final NormalizedNodeAttrBuilder> leafSetEntryBuilder = Builders .leafSetEntryBuilder(); - leafSetEntryBuilder.withNodeIdentifier(new NodeWithValue(qname, val)); + leafSetEntryBuilder.withNodeIdentifier(new NodeWithValue<>(qname, val)); leafSetEntryBuilder.withValue(val); return leafSetEntryBuilder.build(); } diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/test/retest/DataTreeCandidateValidatorTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/test/retest/DataTreeCandidateValidatorTest.java index c8c10f0375..211a50b0a6 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/test/retest/DataTreeCandidateValidatorTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/test/retest/DataTreeCandidateValidatorTest.java @@ -530,7 +530,7 @@ public class DataTreeCandidateValidatorTest { final QName qname, final String val) { final NormalizedNodeAttrBuilder> leafSetEntryBuilder = Builders .leafSetEntryBuilder(); - leafSetEntryBuilder.withNodeIdentifier(new NodeWithValue(qname, val)); + leafSetEntryBuilder.withNodeIdentifier(new NodeWithValue<>(qname, val)); leafSetEntryBuilder.withValue(val); return leafSetEntryBuilder.build(); } diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java index 5735ea0c4e..5b1fdf3cd7 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java @@ -8,7 +8,6 @@ package org.opendaylight.yangtools.yang.data.impl.schema; import static org.junit.Assert.assertEquals; - import com.google.common.base.Function; import com.google.common.collect.Collections2; import com.google.common.io.ByteSource; @@ -19,6 +18,10 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +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.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; @@ -35,18 +38,18 @@ public class InstanceIdToNodesTest { private static final QName ID = QName.create(NS, REVISION, "id"); private SchemaContext ctx; - private final YangInstanceIdentifier.NodeIdentifier rootContainer = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "test")); - private final YangInstanceIdentifier.NodeIdentifier outerContainer = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "outer-container")); - private final YangInstanceIdentifier.NodeIdentifier augmentedLeaf = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "augmented-leaf")); - private final YangInstanceIdentifier.AugmentationIdentifier augmentation = new YangInstanceIdentifier.AugmentationIdentifier(Collections.singleton(augmentedLeaf.getNodeType())); + private final NodeIdentifier rootContainer = new NodeIdentifier(QName.create(NS, REVISION, "test")); + private final NodeIdentifier outerContainer = new NodeIdentifier(QName.create(NS, REVISION, "outer-container")); + private final NodeIdentifier augmentedLeaf = new NodeIdentifier(QName.create(NS, REVISION, "augmented-leaf")); + private final AugmentationIdentifier augmentation = new AugmentationIdentifier(Collections.singleton(augmentedLeaf.getNodeType())); - private final YangInstanceIdentifier.NodeIdentifier outerList = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "outer-list")); - private final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListWithKey = new YangInstanceIdentifier.NodeIdentifierWithPredicates(QName.create(NS, REVISION, "outer-list"), ID, 1); - private final YangInstanceIdentifier.NodeIdentifier choice = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "outer-choice")); - private final YangInstanceIdentifier.NodeIdentifier leafFromCase = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "one")); + private final NodeIdentifier outerList = new NodeIdentifier(QName.create(NS, REVISION, "outer-list")); + private final NodeIdentifierWithPredicates outerListWithKey = new NodeIdentifierWithPredicates(QName.create(NS, REVISION, "outer-list"), ID, 1); + private final NodeIdentifier choice = new NodeIdentifier(QName.create(NS, REVISION, "outer-choice")); + private final NodeIdentifier leafFromCase = new NodeIdentifier(QName.create(NS, REVISION, "one")); - private final YangInstanceIdentifier.NodeIdentifier leafList = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "ordered-leaf-list")); - private final YangInstanceIdentifier.NodeWithValue leafListWithValue = new YangInstanceIdentifier.NodeWithValue(leafList.getNodeType(), "abcd"); + private final NodeIdentifier leafList = new NodeIdentifier(QName.create(NS, REVISION, "ordered-leaf-list")); + private final NodeWithValue leafListWithValue = new NodeWithValue<>(leafList.getNodeType(), "abcd"); static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException { final YangParserImpl parser = new YangParserImpl(); @@ -104,7 +107,7 @@ public class InstanceIdToNodesTest { final ContainerNode expectedFilter = Builders.containerBuilder().withNodeIdentifier(rootContainer).withChild( Builders.mapBuilder().withNodeIdentifier(outerList).withChild( Builders.mapEntryBuilder().withNodeIdentifier(outerListWithKey).withChild( - Builders.leafBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID)).withValue(1).build() + Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(ID)).withValue(1).build() ).withChild( Builders.choiceBuilder().withNodeIdentifier(choice).withChild( Builders.leafBuilder().withNodeIdentifier(leafFromCase).build() @@ -122,7 +125,7 @@ public class InstanceIdToNodesTest { final ContainerNode expectedStructure = Builders.containerBuilder().withNodeIdentifier(rootContainer).withChild( Builders.mapBuilder().withNodeIdentifier(outerList).withChild( Builders.mapEntryBuilder().withNodeIdentifier(outerListWithKey).withChild( - Builders.leafBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID)).withValue(1).build() + Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(ID)).withValue(1).build() ).withChild( Builders.choiceBuilder().withNodeIdentifier(choice).withChild( Builders.leafBuilder().withNodeIdentifier(leafFromCase).build() @@ -138,7 +141,7 @@ public class InstanceIdToNodesTest { @Test public void testListLastChildOverride() throws Exception { final MapEntryNode outerListEntry = Builders.mapEntryBuilder().withNodeIdentifier(outerListWithKey).withChild( - Builders.leafBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID)).withValue(1).build() + Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(ID)).withValue(1).build() ).build(); final MapNode lastChild = Builders.mapBuilder().withNodeIdentifier(this.outerList).withChild( outerListEntry diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java index 38cdb287e4..9125f66180 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java @@ -21,7 +21,10 @@ import java.util.List; import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +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.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; @@ -77,7 +80,7 @@ public class NormalizedDataBuilderTest { @Test public void testSchemaUnaware() throws Exception { // Container - DataContainerNodeBuilder builder = Builders + DataContainerNodeBuilder builder = Builders .containerBuilder().withNodeIdentifier(getNodeIdentifier("container")); // leaf @@ -104,7 +107,7 @@ public class NormalizedDataBuilderTest { .withValue(1).build()) .withChild(Builders.containerBuilder().withNodeIdentifier(getNodeIdentifier("containerInList")).build()) .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifierWithPredicates(getNodeIdentifier("list").getNodeType(), + new NodeIdentifierWithPredicates(getNodeIdentifier("list").getNodeType(), Collections.singletonMap(getNodeIdentifier("uint32InList").getNodeType(), (Object) 1))) .build(); @@ -115,7 +118,7 @@ public class NormalizedDataBuilderTest { AugmentationNode augmentation = Builders .augmentationBuilder() .withNodeIdentifier( - new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(getQName("augmentUint32")))) + new AugmentationIdentifier(Sets.newHashSet(getQName("augmentUint32")))) .withChild( Builders. leafBuilder().withNodeIdentifier(getNodeIdentifier("augmentUint32")) .withValue(11).build()).build(); @@ -130,7 +133,7 @@ public class NormalizedDataBuilderTest { @Test public void testSchemaAware() throws Exception { - DataContainerNodeBuilder builder = Builders + DataContainerNodeBuilder builder = Builders .containerBuilder(containerNode); LeafSchemaNode schemaNode = (LeafSchemaNode) getSchemaNode(schema, "test", "uint32"); @@ -195,8 +198,8 @@ public class NormalizedDataBuilderTest { throw new IllegalStateException("Unable to find child augmentation in " + containerNode); } - private static YangInstanceIdentifier.NodeWithValue getNodeWithValueIdentifier(final String localName, final Object value) { - return new YangInstanceIdentifier.NodeWithValue(getQName(localName), value); + private static NodeWithValue getNodeWithValueIdentifier(final String localName, final T value) { + return new NodeWithValue<>(getQName(localName), value); } private static QName getQName(final String localName) { @@ -204,8 +207,8 @@ public class NormalizedDataBuilderTest { return new QName(URI.create(namespace), localName); } - private static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier(final String localName) { - return new YangInstanceIdentifier.NodeIdentifier(getQName(localName)); + private static NodeIdentifier getNodeIdentifier(final String localName) { + return new NodeIdentifier(getQName(localName)); } public static DataSchemaNode getSchemaNode(final SchemaContext context, final String moduleName, final String childNodeName) { diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/retest/InstanceIdToNodesTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/retest/InstanceIdToNodesTest.java index 4a879b3e01..5aabff3c33 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/retest/InstanceIdToNodesTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/retest/InstanceIdToNodesTest.java @@ -16,6 +16,10 @@ import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +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.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; @@ -34,27 +38,21 @@ public class InstanceIdToNodesTest { private static final QName ID = QName.create(NS, REVISION, "id"); private static SchemaContext ctx; - private final YangInstanceIdentifier.NodeIdentifier rootContainer = new YangInstanceIdentifier.NodeIdentifier( - QName.create(NS, REVISION, "test")); - private final YangInstanceIdentifier.NodeIdentifier outerContainer = new YangInstanceIdentifier.NodeIdentifier( - QName.create(NS, REVISION, "outer-container")); - private final YangInstanceIdentifier.NodeIdentifier augmentedLeaf = new YangInstanceIdentifier.NodeIdentifier( - QName.create(NS, REVISION, "augmented-leaf")); - private final YangInstanceIdentifier.AugmentationIdentifier augmentation = new YangInstanceIdentifier.AugmentationIdentifier( + private final NodeIdentifier rootContainer = new NodeIdentifier(QName.create(NS, REVISION, "test")); + private final NodeIdentifier outerContainer = new NodeIdentifier(QName.create(NS, REVISION, "outer-container")); + private final NodeIdentifier augmentedLeaf = new NodeIdentifier(QName.create(NS, REVISION, "augmented-leaf")); + private final AugmentationIdentifier augmentation = new AugmentationIdentifier( Collections.singleton(augmentedLeaf.getNodeType())); - private final YangInstanceIdentifier.NodeIdentifier outerList = new YangInstanceIdentifier.NodeIdentifier( + private final NodeIdentifier outerList = new NodeIdentifier( QName.create(NS, REVISION, "outer-list")); - private final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListWithKey = new YangInstanceIdentifier.NodeIdentifierWithPredicates( + private final NodeIdentifierWithPredicates outerListWithKey = new NodeIdentifierWithPredicates( QName.create(NS, REVISION, "outer-list"), ID, 1); - private final YangInstanceIdentifier.NodeIdentifier choice = new YangInstanceIdentifier.NodeIdentifier( - QName.create(NS, REVISION, "outer-choice")); - private final YangInstanceIdentifier.NodeIdentifier leafFromCase = new YangInstanceIdentifier.NodeIdentifier( - QName.create(NS, REVISION, "one")); - - private final YangInstanceIdentifier.NodeIdentifier leafList = new YangInstanceIdentifier.NodeIdentifier( - QName.create(NS, REVISION, "ordered-leaf-list")); - private final YangInstanceIdentifier.NodeWithValue leafListWithValue = new YangInstanceIdentifier.NodeWithValue( + private final NodeIdentifier choice = new NodeIdentifier(QName.create(NS, REVISION, "outer-choice")); + private final NodeIdentifier leafFromCase = new NodeIdentifier(QName.create(NS, REVISION, "one")); + + private final NodeIdentifier leafList = new NodeIdentifier(QName.create(NS, REVISION, "ordered-leaf-list")); + private final NodeWithValue leafListWithValue = new NodeWithValue<>( leafList.getNodeType(), "abcd"); static SchemaContext createTestContext() throws URISyntaxException, FileNotFoundException, ReactorException { @@ -122,7 +120,7 @@ public class InstanceIdToNodesTest { .withChild( Builders.leafBuilder() .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(ID)) + new NodeIdentifier(ID)) .withValue(1).build()) .withChild( Builders.choiceBuilder() @@ -152,7 +150,7 @@ public class InstanceIdToNodesTest { .withChild( Builders.leafBuilder() .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(ID)) + new NodeIdentifier(ID)) .withValue(1).build()) .withChild( Builders.choiceBuilder() @@ -174,7 +172,7 @@ public class InstanceIdToNodesTest { .mapEntryBuilder() .withNodeIdentifier(outerListWithKey) .withChild( - Builders.leafBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID)) + Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(ID)) .withValue(1).build()).build(); final MapNode lastChild = Builders.mapBuilder().withNodeIdentifier(this.outerList).withChild(outerListEntry) .build(); diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/retest/NormalizedDataBuilderTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/retest/NormalizedDataBuilderTest.java index 932cf8f1b8..a7d35be318 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/retest/NormalizedDataBuilderTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/retest/NormalizedDataBuilderTest.java @@ -19,7 +19,10 @@ import java.util.List; import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +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.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; @@ -60,7 +63,7 @@ public class NormalizedDataBuilderTest { @Test public void testSchemaUnaware() { // Container - DataContainerNodeBuilder builder = Builders + DataContainerNodeBuilder builder = Builders .containerBuilder().withNodeIdentifier(getNodeIdentifier("container")); // leaf @@ -87,7 +90,7 @@ public class NormalizedDataBuilderTest { .withValue(1).build()) .withChild(Builders.containerBuilder().withNodeIdentifier(getNodeIdentifier("containerInList")).build()) .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifierWithPredicates( + new NodeIdentifierWithPredicates( getNodeIdentifier("list").getNodeType(), Collections.singletonMap( getNodeIdentifier("uint32InList").getNodeType(), (Object) 1))).build(); @@ -98,7 +101,7 @@ public class NormalizedDataBuilderTest { AugmentationNode augmentation = Builders .augmentationBuilder() .withNodeIdentifier( - new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(getQName("augmentUint32")))) + new AugmentationIdentifier(Sets.newHashSet(getQName("augmentUint32")))) .withChild( Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("augmentUint32")) .withValue(11).build()).build(); @@ -113,7 +116,7 @@ public class NormalizedDataBuilderTest { @Test public void testSchemaAware() { - DataContainerNodeBuilder builder = Builders + DataContainerNodeBuilder builder = Builders .containerBuilder(containerNode); LeafSchemaNode schemaNode = (LeafSchemaNode) getSchemaNode(schema, "test", "uint32"); @@ -178,9 +181,8 @@ public class NormalizedDataBuilderTest { throw new IllegalStateException("Unable to find child augmentation in " + containerNode); } - private static YangInstanceIdentifier.NodeWithValue getNodeWithValueIdentifier(final String localName, - final Object value) { - return new YangInstanceIdentifier.NodeWithValue(getQName(localName), value); + private static NodeWithValue getNodeWithValueIdentifier(final String localName, final T value) { + return new NodeWithValue<>(getQName(localName), value); } private static QName getQName(final String localName) { @@ -188,8 +190,8 @@ public class NormalizedDataBuilderTest { return new QName(URI.create(namespace), localName); } - private static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier(final String localName) { - return new YangInstanceIdentifier.NodeIdentifier(getQName(localName)); + private static NodeIdentifier getNodeIdentifier(final String localName) { + return new NodeIdentifier(getQName(localName)); } public static DataSchemaNode getSchemaNode(final SchemaContext context, final String moduleName, diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/NormalizedNodeXmlTranslationTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/NormalizedNodeXmlTranslationTest.java index 3d95e76f4a..fa953eff4b 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/NormalizedNodeXmlTranslationTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/NormalizedNodeXmlTranslationTest.java @@ -52,7 +52,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +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.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; @@ -111,22 +114,17 @@ public class NormalizedNodeXmlTranslationTest { } private static ContainerNode augmentChoiceHell2() { - final YangInstanceIdentifier.NodeIdentifier container = getNodeIdentifier("container"); + final NodeIdentifier container = getNodeIdentifier("container"); QName augmentChoice1QName = QName.create(container.getNodeType(), "augment-choice1"); QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2"); final QName containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container"); final QName leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf"); - final YangInstanceIdentifier.AugmentationIdentifier aug1Id = - new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice1QName)); - final YangInstanceIdentifier.AugmentationIdentifier aug2Id = - new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice2QName)); - final YangInstanceIdentifier.NodeIdentifier augmentChoice1Id = - new YangInstanceIdentifier.NodeIdentifier(augmentChoice1QName); - final YangInstanceIdentifier.NodeIdentifier augmentChoice2Id = - new YangInstanceIdentifier.NodeIdentifier(augmentChoice2QName); - final YangInstanceIdentifier.NodeIdentifier containerId = - new YangInstanceIdentifier.NodeIdentifier(containerQName); + final AugmentationIdentifier aug1Id = new AugmentationIdentifier(Sets.newHashSet(augmentChoice1QName)); + final AugmentationIdentifier aug2Id = new AugmentationIdentifier(Sets.newHashSet(augmentChoice2QName)); + final NodeIdentifier augmentChoice1Id = new NodeIdentifier(augmentChoice1QName); + final NodeIdentifier augmentChoice2Id = new NodeIdentifier(augmentChoice2QName); + final NodeIdentifier containerId = new NodeIdentifier(containerQName); return containerBuilder().withNodeIdentifier(container) @@ -144,7 +142,7 @@ public class NormalizedNodeXmlTranslationTest { } private static ContainerNode withAttributes() { - final DataContainerNodeBuilder b = containerBuilder(); + final DataContainerNodeBuilder b = containerBuilder(); b.withNodeIdentifier(getNodeIdentifier("container")); final CollectionNodeBuilder listBuilder = Builders.mapBuilder().withNodeIdentifier( @@ -153,11 +151,11 @@ public class NormalizedNodeXmlTranslationTest { final Map predicates = Maps.newHashMap(); predicates.put(getNodeIdentifier("uint32InList").getNodeType(), 3L); - final DataContainerNodeBuilder list1Builder = Builders + final DataContainerNodeBuilder list1Builder = Builders .mapEntryBuilder().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifierWithPredicates(getNodeIdentifier("list").getNodeType(), + new NodeIdentifierWithPredicates(getNodeIdentifier("list").getNodeType(), predicates)); - final NormalizedNodeBuilder> uint32InListBuilder + final NormalizedNodeBuilder> uint32InListBuilder = Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("uint32InList")); list1Builder.withChild(uint32InListBuilder.withValue(3L).build()); @@ -165,7 +163,7 @@ public class NormalizedNodeXmlTranslationTest { listBuilder.withChild(list1Builder.build()); b.withChild(listBuilder.build()); - final NormalizedNodeBuilder> booleanBuilder + final NormalizedNodeBuilder> booleanBuilder = Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("boolean")); booleanBuilder.withValue(false); b.withChild(booleanBuilder.build()); @@ -173,8 +171,8 @@ public class NormalizedNodeXmlTranslationTest { final ListNodeBuilder> leafListBuilder = Builders.leafSetBuilder().withNodeIdentifier(getNodeIdentifier("leafList")); - final NormalizedNodeBuilder> leafList1Builder - = Builders.leafSetEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue(getNodeIdentifier("leafList").getNodeType(), "a")); + final NormalizedNodeBuilder> leafList1Builder + = Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue<>(getNodeIdentifier("leafList").getNodeType(), "a")); leafList1Builder.withValue("a"); @@ -186,7 +184,7 @@ public class NormalizedNodeXmlTranslationTest { private static ContainerNode augmentChoiceHell() { - final DataContainerNodeBuilder b = containerBuilder(); + final DataContainerNodeBuilder b = containerBuilder(); b.withNodeIdentifier(getNodeIdentifier("container")); b.withChild( @@ -231,18 +229,18 @@ public class NormalizedNodeXmlTranslationTest { return b.build(); } - private static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier(final String localName) { - return new YangInstanceIdentifier.NodeIdentifier(QName.create(URI.create(NAMESPACE), revision, localName)); + private static NodeIdentifier getNodeIdentifier(final String localName) { + return new NodeIdentifier(QName.create(URI.create(NAMESPACE), revision, localName)); } - public static YangInstanceIdentifier.AugmentationIdentifier getAugmentIdentifier(final String... childNames) { + public static AugmentationIdentifier getAugmentIdentifier(final String... childNames) { final Set qn = Sets.newHashSet(); for (final String childName : childNames) { qn.add(getNodeIdentifier(childName).getNodeType()); } - return new YangInstanceIdentifier.AugmentationIdentifier(qn); + return new AugmentationIdentifier(qn); } public NormalizedNodeXmlTranslationTest(final String yangPath, final String xmlPath, final ContainerNode expectedNode) throws IOException, YangSyntaxErrorException { diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4454Test.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4454Test.java index 1a835c85b3..c509dab1ce 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4454Test.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4454Test.java @@ -19,6 +19,9 @@ import org.junit.Test; import org.opendaylight.yangtools.util.UnmodifiableCollection; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; @@ -76,10 +79,10 @@ public class Bug4454Test { } private final MapEntryNode fooEntryNodeWithValue = ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(new - YangInstanceIdentifier.NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, fooPredicates)). + NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, fooPredicates)). withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "footest")).build(); private final MapEntryNode BazEntryNodeWithValue = ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(new - YangInstanceIdentifier.NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, bazPredicates)). + NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, bazPredicates)). withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "baztest")).build(); private final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo"); @@ -88,18 +91,18 @@ public class Bug4454Test { private final MapEntryNode bazEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "baz"); private final MapNode mapNodeBazFuzWithNodes = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(bazEntryNode).withChild(BazEntryNodeWithValue).withChild(fooEntryNode) .build(); private final MapNode mapNodeFooWithNodes = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(fooEntryNode).withChild(fooEntryNodeWithValue).withChild(barEntryNode).withChild(bazEntryNode) .build(); private final MapNode mapNodeBar = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(barEntryNode).build(); private final MapNode mapNodeBaz = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(bazEntryNode).build(); private InMemoryDataTree inMemoryDataTree; @@ -132,8 +135,7 @@ public class Bug4454Test { Map key = new HashMap<>(); key.put(MIN_MAX_KEY_LEAF_QNAME, "foo"); - YangInstanceIdentifier.NodeIdentifierWithPredicates mapEntryPath2 = new YangInstanceIdentifier - .NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , key); + NodeIdentifierWithPredicates mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , key); YangInstanceIdentifier MIN_MAX_LEAF_FOO = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH) .node(MIN_MAX_LIST_QNAME).node(mapEntryPath2).build(); @@ -141,7 +143,7 @@ public class Bug4454Test { key.clear(); key.put(MIN_MAX_KEY_LEAF_QNAME, "NON-EXISTING-LEAF"); - mapEntryPath2 = new YangInstanceIdentifier.NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key); + mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key); YangInstanceIdentifier MIN_MAX_LEAF_NEL = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node (MIN_MAX_LIST_QNAME).node(mapEntryPath2).build(); @@ -149,8 +151,7 @@ public class Bug4454Test { final Map keyTemp = new HashMap<>(); keyTemp.put(MIN_MAX_KEY_LEAF_QNAME, "baz"); - YangInstanceIdentifier.NodeIdentifierWithPredicates mapEntryPathTest = new YangInstanceIdentifier - .NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , keyTemp); + NodeIdentifierWithPredicates mapEntryPathTest = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , keyTemp); final YangInstanceIdentifier pathToBaz = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH) .node(MIN_MAX_LIST_QNAME).node(mapEntryPathTest).node(MIN_MAX_VALUE_LEAF_QNAME).build(); @@ -158,7 +159,7 @@ public class Bug4454Test { keyTemp.clear(); keyTemp.put(MIN_MAX_KEY_LEAF_QNAME, "bar"); - mapEntryPathTest = new YangInstanceIdentifier.NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , keyTemp); + mapEntryPathTest = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , keyTemp); final YangInstanceIdentifier pathToBar = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH) .node(MIN_MAX_LIST_QNAME).node(mapEntryPathTest).node(MIN_MAX_VALUE_LEAF_QNAME).build(); @@ -166,8 +167,7 @@ public class Bug4454Test { keyTemp.clear(); keyTemp.put(MIN_MAX_KEY_LEAF_QNAME, "foo"); - final YangInstanceIdentifier.NodeIdentifierWithPredicates mapEntryPathTestKey = new YangInstanceIdentifier - .NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , keyTemp); + final NodeIdentifierWithPredicates mapEntryPathTestKey = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , keyTemp); final YangInstanceIdentifier pathToKeyFoo = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH) .node(MIN_MAX_LIST_QNAME).node(mapEntryPathTestKey).node(MIN_MAX_KEY_LEAF_QNAME).build(); @@ -262,8 +262,8 @@ public class Bug4454Test { public void minMaxLeafListPass() throws DataValidationFailedException { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); - final YangInstanceIdentifier.NodeWithValue barPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "bar"); - final YangInstanceIdentifier.NodeWithValue gooPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "goo"); + final NodeWithValue barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar"); + final NodeWithValue gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo"); final LeafSetEntryNode barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create() .withNodeIdentifier(barPath) @@ -273,7 +273,7 @@ public class Bug4454Test { .withValue("goo").build(); final LeafSetNode fooLeafSetNode = ImmutableLeafSetNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) .withChildValue("foo").build(); modificationTree.write(MIN_MAX_LEAF_LIST_PATH, fooLeafSetNode); @@ -299,7 +299,7 @@ public class Bug4454Test { final Optional> masterContainer = snapshotAfterCommit.readNode(MASTER_CONTAINER_PATH); assertTrue(masterContainer.isPresent()); final Optional> leafList = ((NormalizedNodeContainer) masterContainer.get()).getChild( - new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)); + new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)); assertTrue(leafList.isPresent()); assertTrue(leafList.get().getValue().size() == 3); } @@ -312,8 +312,7 @@ public class Bug4454Test { Map key = new HashMap<>(); key.put(MIN_MAX_KEY_LEAF_QNAME, "foo"); - YangInstanceIdentifier.NodeIdentifierWithPredicates mapEntryPath2 = new YangInstanceIdentifier - .NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , key); + NodeIdentifierWithPredicates mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , key); YangInstanceIdentifier MIN_MAX_LEAF_FOO = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH) .node(MIN_MAX_LIST_QNAME).node(mapEntryPath2).build(); @@ -321,7 +320,7 @@ public class Bug4454Test { key.clear(); key.put(MIN_MAX_KEY_LEAF_QNAME, "bar"); - mapEntryPath2 = new YangInstanceIdentifier.NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key); + mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key); YangInstanceIdentifier MIN_MAX_LEAF_BAR = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node (MIN_MAX_LIST_QNAME) @@ -330,7 +329,7 @@ public class Bug4454Test { key.clear(); key.put(MIN_MAX_KEY_LEAF_QNAME, "baz"); - mapEntryPath2 = new YangInstanceIdentifier.NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key); + mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key); YangInstanceIdentifier MIN_MAX_LEAF_BAZ = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node (MIN_MAX_LIST_QNAME) @@ -355,7 +354,7 @@ public class Bug4454Test { final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME , "foo"); final MapNode mapNode1 = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME_NO_MINMAX)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME_NO_MINMAX)) .withChild(fooEntryNode).build(); final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); @@ -363,8 +362,7 @@ public class Bug4454Test { Map key = new HashMap<>(); key.put(MIN_MAX_KEY_LEAF_QNAME, "foo"); - YangInstanceIdentifier.NodeIdentifierWithPredicates mapEntryPath2 = new YangInstanceIdentifier - .NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME_NO_MINMAX , key); + NodeIdentifierWithPredicates mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME_NO_MINMAX , key); YangInstanceIdentifier MIN_MAX_LEAF_FOO = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node (MIN_MAX_LIST_QNAME_NO_MINMAX).node(mapEntryPath2).build(); @@ -372,7 +370,7 @@ public class Bug4454Test { key.clear(); key.put(MIN_MAX_KEY_LEAF_QNAME, "non-existing-leaf"); - mapEntryPath2 = new YangInstanceIdentifier.NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME_NO_MINMAX, key); + mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME_NO_MINMAX, key); YangInstanceIdentifier MIN_MAX_LEAF_NEL = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node (MIN_MAX_LIST_QNAME_NO_MINMAX) diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ListConstraintsValidationTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ListConstraintsValidationTest.java index 961c526065..675de0e86a 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ListConstraintsValidationTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ListConstraintsValidationTest.java @@ -20,6 +20,8 @@ import org.junit.Before; import org.junit.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.NodeWithValue; 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; @@ -104,10 +106,10 @@ public class ListConstraintsValidationTest { final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo"); final MapEntryNode barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar"); final MapNode mapNode1 = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(fooEntryNode).build(); final MapNode mapNode2 = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(barEntryNode).build(); final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); @@ -134,7 +136,7 @@ public class ListConstraintsValidationTest { final MapEntryNode barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar"); final MapEntryNode gooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "goo"); final MapNode mapNode = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(fooEntryNode).build(); final YangInstanceIdentifier fooPath = MIN_MAX_LIST_PATH.node(fooEntryNode.getIdentifier()); @@ -182,8 +184,8 @@ public class ListConstraintsValidationTest { public void minMaxLeafListPass() throws DataValidationFailedException { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); - final YangInstanceIdentifier.NodeWithValue barPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "bar"); - final YangInstanceIdentifier.NodeWithValue gooPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "goo"); + final NodeWithValue barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar"); + final NodeWithValue gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo"); final LeafSetEntryNode barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create() .withNodeIdentifier(barPath) @@ -193,7 +195,7 @@ public class ListConstraintsValidationTest { .withValue("goo").build(); final LeafSetNode fooLeafSetNode = ImmutableLeafSetNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) .withChildValue("foo").build(); modificationTree.write(MIN_MAX_LEAF_LIST_PATH, fooLeafSetNode); @@ -210,7 +212,7 @@ public class ListConstraintsValidationTest { final Optional> masterContainer = snapshotAfterCommit.readNode(MASTER_CONTAINER_PATH); assertTrue(masterContainer.isPresent()); final Optional> leafList = ((NormalizedNodeContainer) masterContainer.get()).getChild( - new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)); + new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)); assertTrue(leafList.isPresent()); assertTrue(leafList.get().getValue().size() == 2); } @@ -219,10 +221,10 @@ public class ListConstraintsValidationTest { public void minMaxLeafListFail() throws DataValidationFailedException { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); - final YangInstanceIdentifier.NodeWithValue fooPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "foo"); - final YangInstanceIdentifier.NodeWithValue barPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "bar"); - final YangInstanceIdentifier.NodeWithValue gooPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "goo"); - final YangInstanceIdentifier.NodeWithValue fuuPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "fuu"); + final NodeWithValue fooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "foo"); + final NodeWithValue barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar"); + final NodeWithValue gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo"); + final NodeWithValue fuuPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "fuu"); final LeafSetEntryNode barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create() .withNodeIdentifier(barPath) @@ -235,7 +237,7 @@ public class ListConstraintsValidationTest { .withValue("fuu").build(); final LeafSetNode fooLeafSetNode = ImmutableLeafSetNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) .withChildValue("foo").build(); modificationTree.write(MIN_MAX_LEAF_LIST_PATH, fooLeafSetNode); @@ -252,12 +254,12 @@ public class ListConstraintsValidationTest { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); final UnkeyedListEntryNode foo = ImmutableUnkeyedListEntryNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LEAF_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME)) .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo")).build(); final List unkeyedEntries = new ArrayList<>(); unkeyedEntries.add(foo); final UnkeyedListNode unkeyedListNode = ImmutableUnkeyedListNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) .withValue(unkeyedEntries).build(); modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.containerNode(MASTER_CONTAINER_QNAME)); @@ -279,16 +281,16 @@ public class ListConstraintsValidationTest { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); final UnkeyedListEntryNode foo = ImmutableUnkeyedListEntryNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LEAF_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME)) .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo")).build(); final UnkeyedListEntryNode bar = ImmutableUnkeyedListEntryNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LEAF_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME)) .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "bar")).build(); final List unkeyedEntries = new ArrayList<>(); unkeyedEntries.add(foo); unkeyedEntries.add(bar); final UnkeyedListNode unkeyedListNode = ImmutableUnkeyedListNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) .withValue(unkeyedEntries).build(); modificationTree.write(UNKEYED_LIST_PATH, unkeyedListNode); diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Retest_ListConstraintsValidation.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Retest_ListConstraintsValidation.java index b0be7ef787..ff7d466a13 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Retest_ListConstraintsValidation.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Retest_ListConstraintsValidation.java @@ -18,6 +18,8 @@ import org.junit.Before; import org.junit.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.NodeWithValue; 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; @@ -106,10 +108,10 @@ public class Retest_ListConstraintsValidation { final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo"); final MapEntryNode barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar"); final MapNode mapNode1 = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(fooEntryNode).build(); final MapNode mapNode2 = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(barEntryNode).build(); final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); @@ -136,7 +138,7 @@ public class Retest_ListConstraintsValidation { final MapEntryNode barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar"); final MapEntryNode gooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "goo"); final MapNode mapNode = ImmutableNodes.mapNodeBuilder() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME)) .withChild(fooEntryNode).build(); final YangInstanceIdentifier fooPath = MIN_MAX_LIST_PATH.node(fooEntryNode.getIdentifier()); @@ -184,8 +186,8 @@ public class Retest_ListConstraintsValidation { public void minMaxLeafListPass() throws DataValidationFailedException { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); - final YangInstanceIdentifier.NodeWithValue barPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "bar"); - final YangInstanceIdentifier.NodeWithValue gooPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "goo"); + final NodeWithValue barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar"); + final NodeWithValue gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo"); final LeafSetEntryNode barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create() .withNodeIdentifier(barPath) @@ -195,7 +197,7 @@ public class Retest_ListConstraintsValidation { .withValue("goo").build(); final LeafSetNode fooLeafSetNode = ImmutableLeafSetNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) .withChildValue("foo").build(); modificationTree.write(MIN_MAX_LEAF_LIST_PATH, fooLeafSetNode); @@ -212,7 +214,7 @@ public class Retest_ListConstraintsValidation { final Optional> masterContainer = snapshotAfterCommit.readNode(MASTER_CONTAINER_PATH); assertTrue(masterContainer.isPresent()); final Optional> leafList = ((NormalizedNodeContainer) masterContainer.get()).getChild( - new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)); + new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)); assertTrue(leafList.isPresent()); assertTrue(leafList.get().getValue().size() == 2); } @@ -221,10 +223,10 @@ public class Retest_ListConstraintsValidation { public void minMaxLeafListFail() throws DataValidationFailedException { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); - final YangInstanceIdentifier.NodeWithValue fooPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "foo"); - final YangInstanceIdentifier.NodeWithValue barPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "bar"); - final YangInstanceIdentifier.NodeWithValue gooPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "goo"); - final YangInstanceIdentifier.NodeWithValue fuuPath = new YangInstanceIdentifier.NodeWithValue(MIN_MAX_LIST_QNAME, "fuu"); + final NodeWithValue fooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "foo"); + final NodeWithValue barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar"); + final NodeWithValue gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo"); + final NodeWithValue fuuPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "fuu"); final LeafSetEntryNode barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create() .withNodeIdentifier(barPath) @@ -237,7 +239,7 @@ public class Retest_ListConstraintsValidation { .withValue("fuu").build(); final LeafSetNode fooLeafSetNode = ImmutableLeafSetNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)) .withChildValue("foo").build(); modificationTree.write(MIN_MAX_LEAF_LIST_PATH, fooLeafSetNode); @@ -254,12 +256,12 @@ public class Retest_ListConstraintsValidation { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); final UnkeyedListEntryNode foo = ImmutableUnkeyedListEntryNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LEAF_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME)) .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo")).build(); final List unkeyedEntries = new ArrayList<>(); unkeyedEntries.add(foo); final UnkeyedListNode unkeyedListNode = ImmutableUnkeyedListNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) .withValue(unkeyedEntries).build(); modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.containerNode(MASTER_CONTAINER_QNAME)); @@ -281,16 +283,16 @@ public class Retest_ListConstraintsValidation { final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification(); final UnkeyedListEntryNode foo = ImmutableUnkeyedListEntryNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LEAF_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME)) .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo")).build(); final UnkeyedListEntryNode bar = ImmutableUnkeyedListEntryNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LEAF_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME)) .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "bar")).build(); final List unkeyedEntries = new ArrayList<>(); unkeyedEntries.add(foo); unkeyedEntries.add(bar); final UnkeyedListNode unkeyedListNode = ImmutableUnkeyedListNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME)) + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) .withValue(unkeyedEntries).build(); modificationTree.write(UNKEYED_LIST_PATH, unkeyedListNode);