This reduces the number of warnings and also the number of required
assertions.
Change-Id: I96456a15ec817b6335572fd373d117af887dd38b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
20 files changed:
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
- final SchemaNode parentNode = schemaContext.getDataChildByName(CONT_1);
+ final SchemaNode parentNode = schemaContext.findDataChildByName(CONT_1).get();
final JsonParserStream jsonParser = JsonParserStream.create(streamWriter,
JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext), parentNode);
jsonParser.parse(new JsonReader(new StringReader(inputJson)));
final JsonParserStream jsonParser = JsonParserStream.create(streamWriter,
JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext), parentNode);
jsonParser.parse(new JsonReader(new StringReader(inputJson)));
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
- final SchemaNode parentNode = schemaContext.getDataChildByName(CONT_1);
+ final SchemaNode parentNode = schemaContext.findDataChildByName(CONT_1).get();
final JsonParserStream jsonParser = JsonParserStream.create(streamWriter,
JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext), parentNode);
jsonParser.parse(new JsonReader(new StringReader(inputJson)));
final JsonParserStream jsonParser = JsonParserStream.create(streamWriter,
JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext), parentNode);
jsonParser.parse(new JsonReader(new StringReader(inputJson)));
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
- final SchemaNode parentNode = schemaContext.getDataChildByName(CONT_1);
+ final SchemaNode parentNode = schemaContext.findDataChildByName(CONT_1).get();
final QName augmentChoice1QName = QName.create(parentNode.getQName(), "augment-choice1");
final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
final QName augmentChoice1QName = QName.create(parentNode.getQName(), "augment-choice1");
final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
SAXException {
schemaContext = YangParserTestUtils.parseYangResourceDirectory("/yang-modeled-anyxml/yang");
final Module bazModule = schemaContext.findModules("baz").iterator().next();
SAXException {
schemaContext = YangParserTestUtils.parseYangResourceDirectory("/yang-modeled-anyxml/yang");
final Module bazModule = schemaContext.findModules("baz").iterator().next();
- final ContainerSchemaNode bazCont = (ContainerSchemaNode) bazModule.getDataChildByName(
- QName.create(bazModule.getQNameModule(), "baz"));
- assertNotNull(bazCont);
+ final ContainerSchemaNode bazCont = (ContainerSchemaNode) bazModule.findDataChildByName(
+ QName.create(bazModule.getQNameModule(), "baz")).get();
final InputStream resourceAsStream = YangModeledAnyXmlSupportTest.class.getResourceAsStream(
"/yang-modeled-anyxml/xml/baz.xml");
final InputStream resourceAsStream = YangModeledAnyXmlSupportTest.class.getResourceAsStream(
"/yang-modeled-anyxml/xml/baz.xml");
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.codec.xml;
import static org.hamcrest.CoreMatchers.containsString;
package org.opendaylight.yangtools.yang.data.codec.xml;
import static org.hamcrest.CoreMatchers.containsString;
import org.junit.Test;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
import org.opendaylight.yangtools.yang.common.QName;
import org.junit.Test;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
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.PathArgument;
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.AnyXmlNode;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
xmlParser.traverse(new DOMSource(doc.getDocumentElement()));
final NormalizedNode<?, ?> parsed = resultHolder.getResult();
xmlParser.traverse(new DOMSource(doc.getDocumentElement()));
final NormalizedNode<?, ?> parsed = resultHolder.getResult();
- final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> editCfg = ((ContainerNode) parsed)
+ final DataContainerChild<? extends PathArgument, ?> editCfg = ((ContainerNode) parsed)
.getChild(getNodeId(parsed, "edit-content")).get();
final DOMSource anyXmlParsedDom = ((AnyXmlNode) ((ChoiceNode) editCfg)
.getChild(getNodeId(parsed, "edit-content")).get();
final DOMSource anyXmlParsedDom = ((AnyXmlNode) ((ChoiceNode) editCfg)
"interface-configurations xmlns=\"http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg\""));
}
"interface-configurations xmlns=\"http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg\""));
}
- private YangInstanceIdentifier.NodeIdentifier getNodeId(final NormalizedNode<?, ?> parsed, final String localName) {
- return new YangInstanceIdentifier.NodeIdentifier(QName.create(parsed.getNodeType(), localName));
+ private static NodeIdentifier getNodeId(final NormalizedNode<?, ?> parsed, final String localName) {
+ return new NodeIdentifier(QName.create(parsed.getNodeType(), localName));
}
private static String toStringDom(final DOMSource source) {
}
private static String toStringDom(final DOMSource source) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.codec.xml;
import static org.junit.Assert.assertEquals;
package org.opendaylight.yangtools.yang.data.codec.xml;
import static org.junit.Assert.assertEquals;
private void testInputXML(final String xmlPath, final String expectedValue) throws Exception {
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(xmlPath);
final Module fooModule = schemaContext.getModules().iterator().next();
private void testInputXML(final String xmlPath, final String expectedValue) throws Exception {
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(xmlPath);
final Module fooModule = schemaContext.getModules().iterator().next();
- final ContainerSchemaNode rootCont = (ContainerSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(), "root"));
- assertNotNull(rootCont);
+ final ContainerSchemaNode rootCont = (ContainerSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "root")).get();
final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream);
final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream);
public void testInstanceIdentifierPathWithEmptyListKey() throws Exception {
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/baz.yang");
final Module bazModule = schemaContext.getModules().iterator().next();
public void testInstanceIdentifierPathWithEmptyListKey() throws Exception {
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/baz.yang");
final Module bazModule = schemaContext.getModules().iterator().next();
- final ContainerSchemaNode topCont = (ContainerSchemaNode) bazModule.getDataChildByName(
- QName.create(bazModule.getQNameModule(), "top-cont"));
- assertNotNull(topCont);
+ final ContainerSchemaNode topCont = (ContainerSchemaNode) bazModule.findDataChildByName(
+ QName.create(bazModule.getQNameModule(), "top-cont")).get();
final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/baz.xml");
final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/baz.xml");
public void testInstanceIdentifierPathWithIdentityrefListKey() throws Exception {
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/zab.yang");
final Module zabModule = schemaContext.getModules().iterator().next();
public void testInstanceIdentifierPathWithIdentityrefListKey() throws Exception {
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/zab.yang");
final Module zabModule = schemaContext.getModules().iterator().next();
- final ContainerSchemaNode topCont = (ContainerSchemaNode) zabModule.getDataChildByName(
- QName.create(zabModule.getQNameModule(), "top-cont"));
- assertNotNull(topCont);
+ final ContainerSchemaNode topCont = (ContainerSchemaNode) zabModule.findDataChildByName(
+ QName.create(zabModule.getQNameModule(), "top-cont")).get();
final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/zab.xml");
final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/zab.xml");
public void testInstanceIdentifierPathWithInstanceIdentifierListKey() throws Exception {
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/foobar.yang");
final Module foobarModule = schemaContext.getModules().iterator().next();
public void testInstanceIdentifierPathWithInstanceIdentifierListKey() throws Exception {
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/foobar.yang");
final Module foobarModule = schemaContext.getModules().iterator().next();
- final ContainerSchemaNode topCont = (ContainerSchemaNode) foobarModule.getDataChildByName(
- QName.create(foobarModule.getQNameModule(), "top-cont"));
- assertNotNull(topCont);
+ final ContainerSchemaNode topCont = (ContainerSchemaNode) foobarModule.findDataChildByName(
+ QName.create(foobarModule.getQNameModule(), "top-cont")).get();
final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/foobar.xml");
final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/foobar.xml");
@Test
public void testParsingEmptyElements() throws Exception {
@Test
public void testParsingEmptyElements() throws Exception {
- final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(), "top-level-container"));
- assertNotNull(topLevelContainer);
+ final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "top-level-container")).get();
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(
"/bug8675/foo.xml");
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(
"/bug8675/foo.xml");
@Test
public void testParsingEmptyRootElement() throws Exception {
@Test
public void testParsingEmptyRootElement() throws Exception {
- final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(), "top-level-container"));
- assertNotNull(topLevelContainer);
+ final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "top-level-container")).get();
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(
"/bug8675/foo-2.xml");
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(
"/bug8675/foo-2.xml");
@Test
public void testListAsRootElement() throws Exception {
@Test
public void testListAsRootElement() throws Exception {
- final ListSchemaNode topLevelList = (ListSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(), "top-level-list"));
- assertNotNull(topLevelList);
+ final ListSchemaNode topLevelList = (ListSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "top-level-list")).get();
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug8675/foo-3.xml");
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug8675/foo-3.xml");
@Test
public void testAnyXmlAsRootElement() throws Exception {
@Test
public void testAnyXmlAsRootElement() throws Exception {
- final AnyXmlSchemaNode topLevelAnyXml = (AnyXmlSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(), "top-level-anyxml"));
- assertNotNull(topLevelAnyXml);
+ final AnyXmlSchemaNode topLevelAnyXml = (AnyXmlSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "top-level-anyxml")).get();
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug8675/foo-4.xml");
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug8675/foo-4.xml");
@Test
public void testLeafAsRootElement() throws Exception {
@Test
public void testLeafAsRootElement() throws Exception {
- final LeafSchemaNode topLevelLeaf = (LeafSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(), "top-level-leaf"));
+ final LeafSchemaNode topLevelLeaf = (LeafSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "top-level-leaf")).get();
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug8675/foo-5.xml");
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug8675/foo-5.xml");
@Test
public void testLeafListAsRootElement() throws Exception {
@Test
public void testLeafListAsRootElement() throws Exception {
- final LeafListSchemaNode topLevelLeafList = (LeafListSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(), "top-level-leaf-list"));
+ final LeafListSchemaNode topLevelLeafList = (LeafListSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "top-level-leaf-list")).get();
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug8675/foo-6.xml");
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug8675/foo-6.xml");
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
"/strict-parsing-mode-test/foo.yang");
final Module fooModule = schemaContext.getModules().iterator().next();
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
"/strict-parsing-mode-test/foo.yang");
final Module fooModule = schemaContext.getModules().iterator().next();
- final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(),
- "top-level-container"));
+ final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "top-level-container")).get();
final InputStream resourceAsStream = StrictParsingModeTest.class.getResourceAsStream(
"/strict-parsing-mode-test/foo.xml");
final InputStream resourceAsStream = StrictParsingModeTest.class.getResourceAsStream(
"/strict-parsing-mode-test/foo.xml");
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
"/strict-parsing-mode-test/foo.yang");
final Module fooModule = schemaContext.getModules().iterator().next();
final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
"/strict-parsing-mode-test/foo.yang");
final Module fooModule = schemaContext.getModules().iterator().next();
- final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.getDataChildByName(
- QName.create(fooModule.getQNameModule(), "top-level-container"));
+ final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.findDataChildByName(
+ QName.create(fooModule.getQNameModule(), "top-level-container")).get();
final InputStream resourceAsStream = StrictParsingModeTest.class.getResourceAsStream(
"/strict-parsing-mode-test/foo.xml");
final InputStream resourceAsStream = StrictParsingModeTest.class.getResourceAsStream(
"/strict-parsing-mode-test/foo.xml");
@Test
public void testRawAnyXMLFromBar() throws Exception {
@Test
public void testRawAnyXMLFromBar() throws Exception {
- DataSchemaNode barContainer = schemaContext.getDataChildByName(QName.create(barModuleQName, "bar"));
+ DataSchemaNode barContainer = schemaContext.findDataChildByName(QName.create(barModuleQName, "bar")).get();
assertTrue(barContainer instanceof ContainerSchemaNode);
final YangModeledAnyXmlSchemaNode yangModeledAnyXML = new YangModeledAnyXMLSchemaNodeImplTest(myAnyXMLDataBar,
(ContainerSchemaNode) barContainer);
assertTrue(barContainer instanceof ContainerSchemaNode);
final YangModeledAnyXmlSchemaNode yangModeledAnyXML = new YangModeledAnyXMLSchemaNodeImplTest(myAnyXMLDataBar,
(ContainerSchemaNode) barContainer);
final InputStream resourceAsStream = YangModeledAnyXMLDeserializationTest.class.getResourceAsStream(
"/anyxml-support/xml/foo.xml");
final Module foo = schemaContext.findModules("foo").iterator().next();
final InputStream resourceAsStream = YangModeledAnyXMLDeserializationTest.class.getResourceAsStream(
"/anyxml-support/xml/foo.xml");
final Module foo = schemaContext.findModules("foo").iterator().next();
- final YangModeledAnyXmlSchemaNode myAnyXmlData = (YangModeledAnyXmlSchemaNode) foo.getDataChildByName(
- QName.create(foo.getQNameModule(), "my-anyxml-data"));
+ final YangModeledAnyXmlSchemaNode myAnyXmlData = (YangModeledAnyXmlSchemaNode) foo.findDataChildByName(
+ QName.create(foo.getQNameModule(), "my-anyxml-data")).get();
final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream);
final NormalizedNodeResult result = new NormalizedNodeResult();
final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream);
final NormalizedNodeResult result = new NormalizedNodeResult();
final YangModeledAnyXmlNode yangModeledAnyXmlNode = (YangModeledAnyXmlNode) output;
DataSchemaNode schemaOfAnyXmlData = yangModeledAnyXmlNode.getSchemaOfAnyXmlData();
final YangModeledAnyXmlNode yangModeledAnyXmlNode = (YangModeledAnyXmlNode) output;
DataSchemaNode schemaOfAnyXmlData = yangModeledAnyXmlNode.getSchemaOfAnyXmlData();
- DataSchemaNode expectedSchemaOfAnyXmlData = schemaContext.getDataChildByName(myContainer2);
+ DataSchemaNode expectedSchemaOfAnyXmlData = schemaContext.findDataChildByName(myContainer2).get();
assertEquals(expectedSchemaOfAnyXmlData, schemaOfAnyXmlData);
Collection<DataContainerChild<? extends PathArgument, ?>> value = yangModeledAnyXmlNode.getValue();
assertEquals(expectedSchemaOfAnyXmlData, schemaOfAnyXmlData);
Collection<DataContainerChild<? extends PathArgument, ?>> value = yangModeledAnyXmlNode.getValue();
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(
"/anyxml-support/serialization/baz.xml");
final Module bazModule = SCHEMA_CONTEXT.findModules("baz").iterator().next();
final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(
"/anyxml-support/serialization/baz.xml");
final Module bazModule = SCHEMA_CONTEXT.findModules("baz").iterator().next();
- final ContainerSchemaNode bazCont = (ContainerSchemaNode) bazModule.getDataChildByName(
- QName.create(bazModule.getQNameModule(), "baz"));
- assertNotNull(bazCont);
+ final ContainerSchemaNode bazCont = (ContainerSchemaNode) bazModule.findDataChildByName(
+ QName.create(bazModule.getQNameModule(), "baz")).get();
final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream);
final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream);
}
private static SchemaNode findChildInCases(final ChoiceSchemaNode parent, final QName qname) {
}
private static SchemaNode findChildInCases(final ChoiceSchemaNode parent, final QName qname) {
- DataSchemaNode schema = null;
for (final CaseSchemaNode caze : parent.getCases().values()) {
for (final CaseSchemaNode caze : parent.getCases().values()) {
- final DataSchemaNode potential = caze.getDataChildByName(qname);
- if (potential != null) {
- schema = potential;
- break;
+ final Optional<DataSchemaNode> potential = caze.findDataChildByName(qname);
+ if (potential.isPresent()) {
+ return potential.get();
}
private static SchemaNode findCaseByChild(final ChoiceSchemaNode parent, final QName qname) {
}
private static SchemaNode findCaseByChild(final ChoiceSchemaNode parent, final QName qname) {
- DataSchemaNode schema = null;
for (final CaseSchemaNode caze : parent.getCases().values()) {
for (final CaseSchemaNode caze : parent.getCases().values()) {
- final DataSchemaNode potential = caze.getDataChildByName(qname);
- if (potential != null) {
- schema = caze;
- break;
+ final Optional<DataSchemaNode> potential = caze.findDataChildByName(qname);
+ if (potential.isPresent()) {
+ return caze;
}
public void startList(final PathArgument name) {
}
public void startList(final PathArgument name) {
}
private static Optional<DataSchemaNode> findChildSchemaNode(final DataNodeContainer parent, final QName child) {
}
private static Optional<DataSchemaNode> findChildSchemaNode(final DataNodeContainer parent, final QName child) {
- DataSchemaNode potential = parent.getDataChildByName(child);
- if (potential == null) {
- potential = findChoice(Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class), child);
- }
- return Optional.ofNullable(potential);
+ final Optional<DataSchemaNode> potential = parent.findDataChildByName(child);
+ return potential.isPresent() ? potential : Optional.ofNullable(
+ findChoice(Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class), child));
}
static InstanceIdToNodes<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) {
}
static InstanceIdToNodes<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) {
private static InstanceIdToNodes<?> fromAugmentation(final DataNodeContainer parent,
final AugmentationTarget parentAug, final DataSchemaNode child) {
for (final AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) {
private static InstanceIdToNodes<?> fromAugmentation(final DataNodeContainer parent,
final AugmentationTarget parentAug, final DataSchemaNode child) {
for (final AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) {
- final DataSchemaNode potential = aug.getDataChildByName(child.getQName());
- if (potential != null) {
+ final Optional<DataSchemaNode> potential = aug.findDataChildByName(child.getQName());
+ if (potential.isPresent()) {
return new InstanceIdToCompositeNodes.AugmentationNormalization(aug, parent);
}
}
return new InstanceIdToCompositeNodes.AugmentationNormalization(aug, parent);
}
}
}
} else if (dsn instanceof ChoiceSchemaNode) {
for (final CaseSchemaNode choiceCase : ((ChoiceSchemaNode) dsn).getCases().values()) {
}
} else if (dsn instanceof ChoiceSchemaNode) {
for (final CaseSchemaNode choiceCase : ((ChoiceSchemaNode) dsn).getCases().values()) {
-
- final DataSchemaNode dataChildByName = choiceCase.getDataChildByName(qname);
- if (dataChildByName != null) {
- return Optional.of(dataChildByName);
+ final Optional<DataSchemaNode> dataChildByName = choiceCase.findDataChildByName(qname);
+ if (dataChildByName.isPresent()) {
+ return dataChildByName;
}
final Optional<DataSchemaNode> foundDsn = findFirstSchema(qname, choiceCase.getChildNodes());
if (foundDsn.isPresent()) {
}
final Optional<DataSchemaNode> foundDsn = findFirstSchema(qname, choiceCase.getChildNodes());
if (foundDsn.isPresent()) {
public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname) {
// Try to find child schema node directly, but use a fallback that compares QNames without revisions
// and auto-expands choices
public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname) {
// Try to find child schema node directly, but use a fallback that compares QNames without revisions
// and auto-expands choices
- final DataSchemaNode dataChildByName = schema.getDataChildByName(qname);
- return dataChildByName == null ? findSchemaForChild(schema, qname, schema.getChildNodes()) : dataChildByName;
+ final Optional<DataSchemaNode> dataChildByName = schema.findDataChildByName(qname);
+ return dataChildByName.isPresent() ? dataChildByName.get()
+ : findSchemaForChild(schema, qname, schema.getChildNodes());
}
public static @Nullable DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname,
}
public static @Nullable DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname,
}
for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) {
}
for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) {
- if (augmentation.getDataChildByName(childSchema.getQName()) != null) {
+ if (augmentation.findDataChildByName(childSchema.getQName()).isPresent()) {
if (child instanceof AugmentationNode
&& belongsToCaseAugment(choiceCaseNode, (AugmentationIdentifier) child.getIdentifier())) {
return Optional.of(choiceCaseNode);
if (child instanceof AugmentationNode
&& belongsToCaseAugment(choiceCaseNode, (AugmentationIdentifier) child.getIdentifier())) {
return Optional.of(choiceCaseNode);
- } else if (choiceCaseNode.getDataChildByName(child.getNodeType()) != null) {
+ } else if (choiceCaseNode.findDataChildByName(child.getNodeType()).isPresent()) {
return Optional.of(choiceCaseNode);
}
}
return Optional.of(choiceCaseNode);
}
}
}
for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) {
}
for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) {
- final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName());
- if (childInAugmentation != null) {
+ final Optional<DataSchemaNode> childInAugmentation = augmentation.findDataChildByName(child.getQName());
+ if (childInAugmentation.isPresent()) {
final QNameModule testModuleQName = QNameModule.create(URI.create("string-pattern-checking-codec-test"));
final Module testModule = schemaContext.findModules("string-pattern-checking-codec-test").iterator().next();
final QNameModule testModuleQName = QNameModule.create(URI.create("string-pattern-checking-codec-test"));
final Module testModule = schemaContext.findModules("string-pattern-checking-codec-test").iterator().next();
- final ContainerSchemaNode testContainer = (ContainerSchemaNode) testModule.getDataChildByName(
- QName.create(testModuleQName, "test-container"));
- assertNotNull(testContainer);
+ final ContainerSchemaNode testContainer = (ContainerSchemaNode) testModule.findDataChildByName(
+ QName.create(testModuleQName, "test-container")).get();
- final LeafSchemaNode testLeaf = (LeafSchemaNode) testContainer.getDataChildByName(
- QName.create(testModuleQName, "string-leaf-with-valid-pattern"));
- assertNotNull(testLeaf);
+ final LeafSchemaNode testLeaf = (LeafSchemaNode) testContainer.findDataChildByName(
+ QName.create(testModuleQName, "string-leaf-with-valid-pattern")).get();
final StringCodec<String> codec = getCodec(testLeaf.getType(), StringCodec.class);
assertNotNull(codec);
final StringCodec<String> codec = getCodec(testLeaf.getType(), StringCodec.class);
assertNotNull(codec);
final DataTreeModification initialDataTreeModification = inMemoryDataTree
.takeSnapshot().newModification();
final DataTreeModification initialDataTreeModification = inMemoryDataTree
.takeSnapshot().newModification();
- final ContainerSchemaNode odlProjContSchemaNode = (ContainerSchemaNode) valModule
- .getDataChildByName(odl);
+ final ContainerSchemaNode odlProjContSchemaNode = (ContainerSchemaNode) valModule.findDataChildByName(odl)
+ .get();
final ContainerNode odlProjectContainer = createOdlContainer(odlProjContSchemaNode);
final ContainerNode odlProjectContainer = createOdlContainer(odlProjContSchemaNode);
private static void writeContributors() {
final ContainerSchemaNode contributorContSchemaNode = (ContainerSchemaNode) valModule
private static void writeContributors() {
final ContainerSchemaNode contributorContSchemaNode = (ContainerSchemaNode) valModule
- .getDataChildByName(odlContributor);
+ .findDataChildByName(odlContributor).get();
final ContainerNode contributorContainer = createBasicContributorContainer(contributorContSchemaNode);
final ContainerNode contributorContainer = createBasicContributorContainer(contributorContSchemaNode);
final YangInstanceIdentifier newOdlProjectMapEntryPath = YangInstanceIdentifier
.of(odl).node(project).node(mapEntryPath);
final YangInstanceIdentifier newOdlProjectMapEntryPath = YangInstanceIdentifier
.of(odl).node(project).node(mapEntryPath);
- final ContainerSchemaNode odlProjContSchemaNode = (ContainerSchemaNode) valModule
- .getDataChildByName(odl);
- final ListSchemaNode projListSchemaNode = (ListSchemaNode) odlProjContSchemaNode
- .getDataChildByName(project);
+ final ContainerSchemaNode odlProjContSchemaNode = (ContainerSchemaNode) valModule.findDataChildByName(odl)
+ .get();
+ final ListSchemaNode projListSchemaNode = (ListSchemaNode) odlProjContSchemaNode.findDataChildByName(project)
+ .get();
final MapEntryNode newProjectMapEntry = createProjectListEntry(
"New Project", "New Project description ...",
"Leader of New Project", "Owner of New Project",
final MapEntryNode newProjectMapEntry = createProjectListEntry(
"New Project", "New Project description ...",
"Leader of New Project", "Owner of New Project",
private static void write() {
final ContainerSchemaNode contributorContSchemaNode = (ContainerSchemaNode) valModule
private static void write() {
final ContainerSchemaNode contributorContSchemaNode = (ContainerSchemaNode) valModule
- .getDataChildByName(odlContributor);
+ .findDataChildByName(odlContributor).get();
final ContainerNode contributorContainer = createContributorContainer(contributorContSchemaNode);
final ContainerNode contributorContainer = createContributorContainer(contributorContSchemaNode);
private static void write2() {
private static void write2() {
- final ContainerSchemaNode odlCon = (ContainerSchemaNode) valModule
- .getDataChildByName(odl);
- final ContainerSchemaNode con1Con = (ContainerSchemaNode) odlCon
- .getDataChildByName(con1);
+ final ContainerSchemaNode odlCon = (ContainerSchemaNode) valModule.findDataChildByName(odl).get();
+ final ContainerSchemaNode con1Con = (ContainerSchemaNode) odlCon.findDataChildByName(con1).get();
final LeafNode<String> l1Leaf = ImmutableNodes.leafNode(l1, "l1 value");
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> containerBuilder = Builders
.containerBuilder(con1Con);
final LeafNode<String> l1Leaf = ImmutableNodes.leafNode(l1, "l1 value");
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> containerBuilder = Builders
.containerBuilder(con1Con);
final ContainerSchemaNode contributorContSchemaNode) {
final ListSchemaNode contributorListSchemaNode = (ListSchemaNode) contributorContSchemaNode
final ContainerSchemaNode contributorContSchemaNode) {
final ListSchemaNode contributorListSchemaNode = (ListSchemaNode) contributorContSchemaNode
- .getDataChildByName(contributor);
+ .findDataChildByName(contributor).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contributorContainerBldr = Builders
.containerBuilder(contributorContSchemaNode);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contributorContainerBldr = Builders
.containerBuilder(contributorContSchemaNode);
final String odlProjectNameVal, final String odlProjectDescVal,
final ListSchemaNode contributorListSchemaNode) {
final String odlProjectNameVal, final String odlProjectDescVal,
final ListSchemaNode contributorListSchemaNode) {
- final LeafNode<String> loginLeaf = ImmutableNodes.leafNode(login,
- loginVal);
- final LeafNode<String> contributorNameLeaf = ImmutableNodes.leafNode(
- contributorName, contributorNameVal);
- final LeafNode<String> odlProjectNameLeafRef = ImmutableNodes.leafNode(
- odlProjectName, odlProjectNameVal);
- final LeafNode<String> odlProjectDescLeafRef = ImmutableNodes.leafNode(
- odlProjectDesc, odlProjectDescVal);
+ final LeafNode<String> loginLeaf = ImmutableNodes.leafNode(login, loginVal);
+ final LeafNode<String> contributorNameLeaf = ImmutableNodes.leafNode(contributorName, contributorNameVal);
+ final LeafNode<String> odlProjectNameLeafRef = ImmutableNodes.leafNode(odlProjectName, odlProjectNameVal);
+ final LeafNode<String> odlProjectDescLeafRef = ImmutableNodes.leafNode(odlProjectDesc, odlProjectDescVal);
return Builders.mapEntryBuilder(contributorListSchemaNode)
.addChild(loginLeaf)
return Builders.mapEntryBuilder(contributorListSchemaNode)
.addChild(loginLeaf)
private static ContainerNode createOdlContainer(
final ContainerSchemaNode container) {
private static ContainerNode createOdlContainer(
final ContainerSchemaNode container) {
- final ListSchemaNode projListSchemaNode = (ListSchemaNode) container
- .getDataChildByName(project);
+ final ListSchemaNode projListSchemaNode = (ListSchemaNode) container.findDataChildByName(project).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> odlProjectContainerBldr = Builders
.containerBuilder(container);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> odlProjectContainerBldr = Builders
.containerBuilder(container);
final ContainerSchemaNode contributorContSchemaNode) {
final ListSchemaNode contributorListSchemaNode = (ListSchemaNode) contributorContSchemaNode
final ContainerSchemaNode contributorContSchemaNode) {
final ListSchemaNode contributorListSchemaNode = (ListSchemaNode) contributorContSchemaNode
- .getDataChildByName(contributor);
+ .findDataChildByName(contributor).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contributorContainerBldr = Builders
.containerBuilder(contributorContSchemaNode);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contributorContainerBldr = Builders
.containerBuilder(contributorContSchemaNode);
inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
- final ContainerSchemaNode chipsListContSchemaNode = (ContainerSchemaNode) mainModule.getDataChildByName(chips);
+ final ContainerSchemaNode chipsListContSchemaNode = (ContainerSchemaNode) mainModule.findDataChildByName(chips)
+ .get();
final ContainerNode chipsContainer = createChipsContainer(chipsListContSchemaNode);
final YangInstanceIdentifier path1 = YangInstanceIdentifier.of(chips);
initialDataTreeModification.write(path1, chipsContainer);
final ContainerSchemaNode devTypesListContSchemaNode = (ContainerSchemaNode) mainModule
final ContainerNode chipsContainer = createChipsContainer(chipsListContSchemaNode);
final YangInstanceIdentifier path1 = YangInstanceIdentifier.of(chips);
initialDataTreeModification.write(path1, chipsContainer);
final ContainerSchemaNode devTypesListContSchemaNode = (ContainerSchemaNode) mainModule
- .getDataChildByName(deviceTypeStr);
+ .findDataChildByName(deviceTypeStr).get();
final ContainerNode deviceTypesContainer = createDevTypeStrContainer(devTypesListContSchemaNode);
final YangInstanceIdentifier path2 = YangInstanceIdentifier.of(deviceTypeStr);
initialDataTreeModification.write(path2, deviceTypesContainer);
final ContainerNode deviceTypesContainer = createDevTypeStrContainer(devTypesListContSchemaNode);
final YangInstanceIdentifier path2 = YangInstanceIdentifier.of(deviceTypeStr);
initialDataTreeModification.write(path2, deviceTypesContainer);
private static void writeDevices() {
private static void writeDevices() {
- final ContainerSchemaNode devicesContSchemaNode = (ContainerSchemaNode) mainModule.getDataChildByName(devices);
+ final ContainerSchemaNode devicesContSchemaNode = (ContainerSchemaNode) mainModule.findDataChildByName(devices)
+ .get();
final ContainerNode devicesContainer = createDevicesContainer(devicesContSchemaNode);
final ContainerNode devicesContainer = createDevicesContainer(devicesContSchemaNode);
private static ContainerNode createDevTypeStrContainer(final ContainerSchemaNode container) {
private static ContainerNode createDevTypeStrContainer(final ContainerSchemaNode container) {
- final ListSchemaNode devTypeListSchemaNode = (ListSchemaNode) container.getDataChildByName(deviceType);
+ final ListSchemaNode devTypeListSchemaNode = (ListSchemaNode) container.findDataChildByName(deviceType).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devTypeContainerBldr = Builders
.containerBuilder(container);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devTypeContainerBldr = Builders
.containerBuilder(container);
private static ContainerNode createChipsContainer(final ContainerSchemaNode container) {
private static ContainerNode createChipsContainer(final ContainerSchemaNode container) {
- final ListSchemaNode chipsListSchemaNode = (ListSchemaNode) container.getDataChildByName(chip);
+ final ListSchemaNode chipsListSchemaNode = (ListSchemaNode) container.findDataChildByName(chip).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> chipsContainerBldr = Builders
.containerBuilder(container);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> chipsContainerBldr = Builders
.containerBuilder(container);
private static ContainerNode createDevicesContainer(final ContainerSchemaNode container) {
private static ContainerNode createDevicesContainer(final ContainerSchemaNode container) {
- final ListSchemaNode devicesListSchemaNode = (ListSchemaNode) container.getDataChildByName(device);
+ final ListSchemaNode devicesListSchemaNode = (ListSchemaNode) container.findDataChildByName(device).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devicesContainerBldr = Builders
.containerBuilder(container);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devicesContainerBldr = Builders
.containerBuilder(container);
final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
- final ContainerSchemaNode chipsListContSchemaNode = (ContainerSchemaNode) mainModule.getDataChildByName(chips);
+ final ContainerSchemaNode chipsListContSchemaNode = (ContainerSchemaNode) mainModule.findDataChildByName(chips)
+ .get();
final ContainerNode chipsContainer = createChipsContainer(chipsListContSchemaNode);
final YangInstanceIdentifier path1 = YangInstanceIdentifier.of(chips);
initialDataTreeModification.write(path1, chipsContainer);
final ContainerSchemaNode devTypesListContSchemaNode = (ContainerSchemaNode) mainModule
final ContainerNode chipsContainer = createChipsContainer(chipsListContSchemaNode);
final YangInstanceIdentifier path1 = YangInstanceIdentifier.of(chips);
initialDataTreeModification.write(path1, chipsContainer);
final ContainerSchemaNode devTypesListContSchemaNode = (ContainerSchemaNode) mainModule
- .getDataChildByName(deviceTypeStr);
+ .findDataChildByName(deviceTypeStr).get();
final ContainerNode deviceTypesContainer = createDevTypeStrContainer(devTypesListContSchemaNode);
final YangInstanceIdentifier path2 = YangInstanceIdentifier.of(deviceTypeStr);
initialDataTreeModification.write(path2, deviceTypesContainer);
final ContainerNode deviceTypesContainer = createDevTypeStrContainer(devTypesListContSchemaNode);
final YangInstanceIdentifier path2 = YangInstanceIdentifier.of(deviceTypeStr);
initialDataTreeModification.write(path2, deviceTypesContainer);
private static void writeDevices() {
private static void writeDevices() {
- final ContainerSchemaNode devicesContSchemaNode = (ContainerSchemaNode) mainModule.getDataChildByName(devices);
+ final ContainerSchemaNode devicesContSchemaNode = (ContainerSchemaNode) mainModule.findDataChildByName(devices)
+ .get();
final ContainerNode devicesContainer = createDevicesContainer(devicesContSchemaNode);
final ContainerNode devicesContainer = createDevicesContainer(devicesContSchemaNode);
private static void mergeDevices() {
private static void mergeDevices() {
- final ContainerSchemaNode devicesContSchemaNode = (ContainerSchemaNode) mainModule.getDataChildByName(devices);
+ final ContainerSchemaNode devicesContSchemaNode = (ContainerSchemaNode) mainModule.findDataChildByName(devices)
+ .get();
final ContainerNode devicesContainer = createDevices2Container(devicesContSchemaNode);
final ContainerNode devicesContainer = createDevices2Container(devicesContSchemaNode);
private static ContainerNode createDevTypeStrContainer(final ContainerSchemaNode container) {
private static ContainerNode createDevTypeStrContainer(final ContainerSchemaNode container) {
- final ListSchemaNode devTypeListSchemaNode = (ListSchemaNode) container.getDataChildByName(deviceType);
+ final ListSchemaNode devTypeListSchemaNode = (ListSchemaNode) container.findDataChildByName(deviceType).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devTypeContainerBldr = Builders
.containerBuilder(container);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devTypeContainerBldr = Builders
.containerBuilder(container);
private static ContainerNode createChipsContainer(final ContainerSchemaNode container) {
private static ContainerNode createChipsContainer(final ContainerSchemaNode container) {
- final ListSchemaNode chipsListSchemaNode = (ListSchemaNode) container.getDataChildByName(chip);
+ final ListSchemaNode chipsListSchemaNode = (ListSchemaNode) container.findDataChildByName(chip).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> chipsContainerBldr = Builders
.containerBuilder(container);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> chipsContainerBldr = Builders
.containerBuilder(container);
private static ContainerNode createDevicesContainer(final ContainerSchemaNode container) {
private static ContainerNode createDevicesContainer(final ContainerSchemaNode container) {
- final ListSchemaNode devicesListSchemaNode = (ListSchemaNode) container.getDataChildByName(device);
+ final ListSchemaNode devicesListSchemaNode = (ListSchemaNode) container.findDataChildByName(device).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devicesContainerBldr = Builders
.containerBuilder(container);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devicesContainerBldr = Builders
.containerBuilder(container);
private static ContainerNode createDevices2Container(final ContainerSchemaNode container) {
private static ContainerNode createDevices2Container(final ContainerSchemaNode container) {
- final ListSchemaNode devicesListSchemaNode = (ListSchemaNode) container.getDataChildByName(device);
+ final ListSchemaNode devicesListSchemaNode = (ListSchemaNode) container.findDataChildByName(device).get();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devicesContainerBldr = Builders
.containerBuilder(container);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> devicesContainerBldr = Builders
.containerBuilder(container);
final QName q5 = QName.create(root, "list1");
final QName q6 = QName.create(root, "name");
final QName q5 = QName.create(root, "list1");
final QName q6 = QName.create(root, "name");
- final DataSchemaNode leafRefNode = rootMod.getDataChildByName(q1);
- final DataSchemaNode targetNode = rootMod.getDataChildByName(q2);
- final DataSchemaNode cont1Node = rootMod.getDataChildByName(q3);
- final DataSchemaNode cont2Node = rootMod.getDataChildByName(q4);
+ final DataSchemaNode leafRefNode = rootMod.findDataChildByName(q1).get();
+ final DataSchemaNode targetNode = rootMod.findDataChildByName(q2).get();
+ final DataSchemaNode cont1Node = rootMod.findDataChildByName(q3).get();
+ final DataSchemaNode cont2Node = rootMod.findDataChildByName(q4).get();
final DataSchemaNode name1Node = ((DataNodeContainer) ((DataNodeContainer) rootMod.getDataChildByName(q3))
.getDataChildByName(q5)).getDataChildByName(q6);
final DataSchemaNode name1Node = ((DataNodeContainer) ((DataNodeContainer) rootMod.getDataChildByName(q3))
.getDataChildByName(q5)).getDataChildByName(q6);
@Test
public void leafRefContextUtilsTest3() {
final QName q16 = QName.create(tst, "con1");
@Test
public void leafRefContextUtilsTest3() {
final QName q16 = QName.create(tst, "con1");
- final DataSchemaNode con1 = tstMod.getDataChildByName(q16);
- final List<LeafRefContext> allLeafRefChilds = LeafRefContextUtils
- .findAllLeafRefChilds(con1, rootLeafRefContext);
+ final DataSchemaNode con1 = tstMod.findDataChildByName(q16).get();
+ final List<LeafRefContext> allLeafRefChilds = LeafRefContextUtils.findAllLeafRefChilds(con1,
+ rootLeafRefContext);
assertNotNull(allLeafRefChilds);
assertFalse(allLeafRefChilds.isEmpty());
assertEquals(4, allLeafRefChilds.size());
final QName q17 = QName.create(tst, "odl-contributor");
assertNotNull(allLeafRefChilds);
assertFalse(allLeafRefChilds.isEmpty());
assertEquals(4, allLeafRefChilds.size());
final QName q17 = QName.create(tst, "odl-contributor");
- final DataSchemaNode odlContributorNode = tstMod.getDataChildByName(q17);
+ final DataSchemaNode odlContributorNode = tstMod.findDataChildByName(q17).get();
List<LeafRefContext> allChildsReferencedByLeafRef = LeafRefContextUtils.findAllChildsReferencedByLeafRef(
odlContributorNode, rootLeafRefContext);
List<LeafRefContext> allChildsReferencedByLeafRef = LeafRefContextUtils.findAllChildsReferencedByLeafRef(
odlContributorNode, rootLeafRefContext);
.toURI());
final SchemaContext schema = YangParserTestUtils.parseYangFiles(leafRefTestYang);
final Module module = schema.getModules().iterator().next();
.toURI());
final SchemaContext schema = YangParserTestUtils.parseYangFiles(leafRefTestYang);
final Module module = schema.getModules().iterator().next();
- final DataSchemaNode root = module.getDataChildByName(ROOT_CONTAINER);
- list = (ListSchemaNode)((ContainerSchemaNode) root).getDataChildByName(LIST_MAIN);
- leafList = (LeafListSchemaNode)((ContainerSchemaNode) root).getDataChildByName(LEAF_LIST_MAIN);
+ final DataSchemaNode root = module.findDataChildByName(ROOT_CONTAINER).get();
+ list = (ListSchemaNode)((ContainerSchemaNode) root).findDataChildByName(LIST_MAIN).get();
+ leafList = (LeafListSchemaNode)((ContainerSchemaNode) root).findDataChildByName(LEAF_LIST_MAIN).get();
private static AugmentationSchemaNode getAugmentationSchemaForChild(final ContainerSchemaNode containerNode,
final QName qname) {
for (AugmentationSchemaNode augmentationSchema : containerNode.getAvailableAugmentations()) {
private static AugmentationSchemaNode getAugmentationSchemaForChild(final ContainerSchemaNode containerNode,
final QName qname) {
for (AugmentationSchemaNode augmentationSchema : containerNode.getAvailableAugmentations()) {
- if (augmentationSchema.getDataChildByName(qname) != null) {
+ if (augmentationSchema.findDataChildByName(qname).isPresent()) {
return augmentationSchema;
}
}
return augmentationSchema;
}
}