本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode.getDataChildByName方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerSchemaNode.getDataChildByName方法的具体用法?Java ContainerSchemaNode.getDataChildByName怎么用?Java ContainerSchemaNode.getDataChildByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
的用法示例。
在下文中一共展示了ContainerSchemaNode.getDataChildByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOdlContainer
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
private static ContainerNode createOdlContainer(
final ContainerSchemaNode container) {
final ListSchemaNode projListSchemaNode = (ListSchemaNode) container
.getDataChildByName(project);
final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> odlProjectContainerBldr = Builders
.containerBuilder(container);
final MapNode projectMap = createProjectList(projListSchemaNode);
odlProjectContainerBldr.addChild(projectMap);
final ContainerNode odlProjectContainer = odlProjectContainerBldr
.build();
return odlProjectContainer;
}
示例2: testIfFeatureStatementBeingIgnoredInYangDataBody
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testIfFeatureStatementBeingIgnoredInYangDataBody() throws Exception {
final SchemaContext schemaContext = reactor.newBuild().setSupportedFeatures(ImmutableSet.of())
.addSources(FOOBAR_MODULE, IETF_RESTCONF_MODULE).buildEffective();
assertNotNull(schemaContext);
final Module foobar = schemaContext.findModule("foobar", REVISION).get();
final List<UnknownSchemaNode> unknownSchemaNodes = foobar.getUnknownSchemaNodes();
assertEquals(1, unknownSchemaNodes.size());
final UnknownSchemaNode unknownSchemaNode = unknownSchemaNodes.iterator().next();
assertTrue(unknownSchemaNode instanceof YangDataSchemaNode);
final YangDataSchemaNode myYangDataNode = (YangDataSchemaNode) unknownSchemaNode;
assertNotNull(myYangDataNode);
final ContainerSchemaNode contInYangData = myYangDataNode.getContainerSchemaNode();
assertNotNull(contInYangData);
final ContainerSchemaNode innerCont = (ContainerSchemaNode) contInYangData.getDataChildByName(
QName.create(foobar.getQNameModule(), "inner-cont"));
assertNotNull(innerCont);
final ContainerSchemaNode grpCont = (ContainerSchemaNode) contInYangData.getDataChildByName(
QName.create(foobar.getQNameModule(), "grp-cont"));
assertNotNull(grpCont);
}
示例3: testAugmentInUsesResolving
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testAugmentInUsesResolving() throws Exception {
final SchemaContext context = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-uses")
.toURI());
assertEquals(1, context.getModules().size());
final Module test = context.getModules().iterator().next();
final DataNodeContainer links = (DataNodeContainer) test.getDataChildByName(QName.create(test.getQNameModule(),
"links"));
final DataNodeContainer link = (DataNodeContainer) links.getDataChildByName(QName.create(test.getQNameModule(),
"link"));
final DataNodeContainer nodes = (DataNodeContainer) link.getDataChildByName(QName.create(test.getQNameModule(),
"nodes"));
final ContainerSchemaNode node = (ContainerSchemaNode) nodes.getDataChildByName(QName.create(
test.getQNameModule(), "node"));
final Set<AugmentationSchemaNode> augments = node.getAvailableAugmentations();
assertEquals(1, augments.size());
assertEquals(1, node.getChildNodes().size());
final LeafSchemaNode id = (LeafSchemaNode) node.getDataChildByName(QName.create(test.getQNameModule(), "id"));
assertTrue(id.isAugmenting());
}
示例4: caseShortHandAugmentingTest
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void caseShortHandAugmentingTest() throws Exception {
final SchemaContext context = StmtTestUtils.parseYangSources("/choice-case-type-test-models");
assertNotNull(context);
final String rev = "2013-07-01";
final String ns = "urn:ietf:params:xml:ns:yang:choice-monitoring";
final String nsAug = "urn:ietf:params:xml:ns:yang:augment-monitoring";
final ContainerSchemaNode netconf = (ContainerSchemaNode) context.getDataChildByName(QName.create(ns, rev,
"netconf-state"));
final ContainerSchemaNode datastores = (ContainerSchemaNode) netconf.getDataChildByName(QName.create(ns, rev,
"datastores"));
final ListSchemaNode datastore = (ListSchemaNode) datastores.getDataChildByName(QName.create(ns, rev,
"datastore"));
final ContainerSchemaNode locks = (ContainerSchemaNode) datastore.getDataChildByName(QName.create(ns, rev,
"locks"));
final ChoiceSchemaNode lockType = (ChoiceSchemaNode) locks.getDataChildByName(QName
.create(ns, rev, "lock-type"));
final CaseSchemaNode leafAugCase = lockType.findCaseNodes("leaf-aug-case").iterator().next();
assertTrue(leafAugCase.isAugmenting());
final DataSchemaNode leafAug = leafAugCase.getDataChildByName(QName.create(nsAug, rev, "leaf-aug-case"));
assertFalse(leafAug.isAugmenting());
}
示例5: getEffectiveUnits
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
private static UnitsEffectiveStatement getEffectiveUnits(final Module module, final QName containerQName,
final QName leafQName) {
UnitsEffectiveStatement units = null;
final ContainerSchemaNode cont = (ContainerSchemaNode) module.getDataChildByName(containerQName);
assertNotNull(cont);
final LeafSchemaNode leaf = (LeafSchemaNode) cont.getDataChildByName(leafQName);
assertNotNull(leaf);
for (EffectiveStatement<?, ?> effStmt : ((LeafEffectiveStatement) leaf).effectiveSubstatements()) {
if (effStmt instanceof UnitsEffectiveStatement) {
units = (UnitsEffectiveStatement) effStmt;
break;
}
}
return units;
}
示例6: testBug5884
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testBug5884() throws Exception {
final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5884");
assertNotNull(context);
final QName root = QName.create(NS, REV, "main-container");
final QName choice = QName.create(NS, REV, "test-choice");
final QName testContainerQname = QName.create(NS, REV, "test");
final Module foo = context.findModule("foo", Revision.of("2016-01-01")).get();
final ContainerSchemaNode rootContainer = (ContainerSchemaNode) context.getDataChildByName(root);
final ContainerSchemaNode testContainer = (ContainerSchemaNode) rootContainer.getDataChildByName(
testContainerQname);
final ChoiceSchemaNode dataChildByName = (ChoiceSchemaNode) testContainer.getDataChildByName(choice);
final Set<AugmentationSchemaNode> augmentations = foo.getAugmentations();
final Set<AugmentationSchemaNode> availableAugmentations = dataChildByName.getAvailableAugmentations();
final Iterator<AugmentationSchemaNode> iterator = augmentations.iterator();
final Iterator<AugmentationSchemaNode> availableIterator = availableAugmentations.iterator();
testIterator(iterator);
testIterator(availableIterator);
}
示例7: testChoice
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testChoice() {
final ContainerSchemaNode transfer = (ContainerSchemaNode) foo.getDataChildByName(
QName.create(foo.getQNameModule(), "transfer"));
final ChoiceSchemaNode how = (ChoiceSchemaNode) transfer.getDataChildByName(
QName.create(foo.getQNameModule(), "how"));
final SortedMap<QName, CaseSchemaNode> cases = how.getCases();
assertEquals(5, cases.size());
CaseSchemaNode input = null;
CaseSchemaNode output = null;
for (final CaseSchemaNode caseNode : cases.values()) {
if ("input".equals(caseNode.getQName().getLocalName())) {
input = caseNode;
} else if ("output".equals(caseNode.getQName().getLocalName())) {
output = caseNode;
}
}
assertNotNull(input);
assertNotNull(input.getPath());
assertNotNull(output);
assertNotNull(output.getPath());
}
示例8: testAugment
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testAugment() throws ReactorException {
final StatementStreamSource resource = sourceForResource("/context-augment-test/test4.yang");
final StatementStreamSource test1 = sourceForResource("/context-augment-test/test1.yang");
final StatementStreamSource test2 = sourceForResource("/context-augment-test/test2.yang");
final StatementStreamSource test3 = sourceForResource("/context-augment-test/test3.yang");
final SchemaContext context = TestUtils.parseYangSources(resource, test1, test2, test3);
final Module t4 = TestUtils.findModule(context, "test4").get();
final ContainerSchemaNode interfaces = (ContainerSchemaNode) t4.getDataChildByName(QName.create(
t4.getQNameModule(), "interfaces"));
final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(t4.getQNameModule(),
"ifEntry"));
// test augmentation process
final ContainerSchemaNode augmentHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(T3_NS,
REV, "augment-holder"));
assertNotNull(augmentHolder);
final DataSchemaNode ds0 = augmentHolder.getDataChildByName(QName.create(T2_NS, REV, "ds0ChannelNumber"));
assertNotNull(ds0);
final DataSchemaNode interfaceId = augmentHolder.getDataChildByName(QName.create(T2_NS, REV, "interface-id"));
assertNotNull(interfaceId);
final DataSchemaNode higherLayerIf = augmentHolder.getDataChildByName(QName.create(T2_NS, REV,
"higher-layer-if"));
assertNotNull(higherLayerIf);
final ContainerSchemaNode schemas = (ContainerSchemaNode) augmentHolder.getDataChildByName(QName.create(T2_NS,
REV, "schemas"));
assertNotNull(schemas);
assertNotNull(schemas.getDataChildByName(QName.create(T1_NS, REV, "id")));
// test augment target after augmentation: check if it is same instance
final ListSchemaNode ifEntryAfterAugment = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
t4.getQNameModule(), "ifEntry"));
assertTrue(ifEntry == ifEntryAfterAugment);
}
示例9: verifyExtendedLeaf
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
private static void verifyExtendedLeaf(final ContainerSchemaNode topContainer) {
DataSchemaNode dataChildByName2 = topContainer.getDataChildByName(QName.create("http://example.com/module2",
"2016-03-09", "extended-leaf"));
assertTrue(dataChildByName2 instanceof LeafSchemaNode);
LeafSchemaNode extendedLeaf = (LeafSchemaNode) dataChildByName2;
RevisionAwareXPath whenConditionExtendedLeaf = extendedLeaf.getWhenCondition().get();
assertEquals(new RevisionAwareXPathImpl("module1:top = 'extended'", false), whenConditionExtendedLeaf);
assertEquals(Status.DEPRECATED, extendedLeaf.getStatus());
assertEquals(Optional.of("text"), extendedLeaf.getDescription());
assertEquals(Optional.of("ref"), extendedLeaf.getReference());
}
示例10: testConfigStatementBeingIgnoredInYangDataBody
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testConfigStatementBeingIgnoredInYangDataBody() throws Exception {
final SchemaContext schemaContext = reactor.newBuild().addSources(BAZ_MODULE, IETF_RESTCONF_MODULE)
.buildEffective();
assertNotNull(schemaContext);
final Module baz = schemaContext.findModule("baz", REVISION).get();
final List<UnknownSchemaNode> unknownSchemaNodes = baz.getUnknownSchemaNodes();
assertEquals(1, unknownSchemaNodes.size());
final UnknownSchemaNode unknownSchemaNode = unknownSchemaNodes.iterator().next();
assertTrue(unknownSchemaNode instanceof YangDataSchemaNode);
final YangDataSchemaNode myYangDataNode = (YangDataSchemaNode) unknownSchemaNode;
assertNotNull(myYangDataNode);
final ContainerSchemaNode contInYangData = myYangDataNode.getContainerSchemaNode();
assertNotNull(contInYangData);
assertTrue(contInYangData.isConfiguration());
final ContainerSchemaNode innerCont = (ContainerSchemaNode) contInYangData.getDataChildByName(
QName.create(baz.getQNameModule(), "inner-cont"));
assertNotNull(innerCont);
assertTrue(innerCont.isConfiguration());
final ContainerSchemaNode grpCont = (ContainerSchemaNode) contInYangData.getDataChildByName(
QName.create(baz.getQNameModule(), "grp-cont"));
assertNotNull(grpCont);
assertTrue(grpCont.isConfiguration());
}
示例11: salDomBrokerImplModuleTest
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
private static void salDomBrokerImplModuleTest(final SchemaContext context) {
final Module module = context.findModule("opendaylight-sal-dom-broker-impl", Revision.of("2013-10-28")).get();
final Set<AugmentationSchemaNode> augmentations = module.getAugmentations();
boolean checked = false;
for (final AugmentationSchemaNode augmentationSchema : augmentations) {
final DataSchemaNode dataNode = augmentationSchema
.getDataChildByName(QName.create(module.getQNameModule(), "dom-broker-impl"));
if (dataNode instanceof CaseSchemaNode) {
final CaseSchemaNode caseNode = (CaseSchemaNode) dataNode;
final DataSchemaNode dataNode2 = caseNode
.getDataChildByName(QName.create(module.getQNameModule(), "async-data-broker"));
if (dataNode2 instanceof ContainerSchemaNode) {
final ContainerSchemaNode containerNode = (ContainerSchemaNode) dataNode2;
final DataSchemaNode leaf = containerNode
.getDataChildByName(QName.create(module.getQNameModule(), "type"));
final List<UnknownSchemaNode> unknownSchemaNodes = leaf.getUnknownSchemaNodes();
assertEquals(1, unknownSchemaNodes.size());
final UnknownSchemaNode unknownSchemaNode = unknownSchemaNodes.get(0);
assertEquals("dom-async-data-broker", unknownSchemaNode.getQName().getLocalName());
assertEquals(unknownSchemaNode.getQName(), unknownSchemaNode.getPath().getLastComponent());
checked = true;
}
}
}
assertTrue(checked);
}
示例12: writeMapEntry
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
private static void writeMapEntry() {
final Map<QName, Object> keys = new HashMap<>();
keys.put(name, "New Project");
final NodeIdentifierWithPredicates mapEntryPath = new NodeIdentifierWithPredicates(
project, keys);
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 MapEntryNode newProjectMapEntry = createProjectListEntry(
"New Project", "New Project description ...",
"Leader of New Project", "Owner of New Project",
projListSchemaNode);
final DataTreeModification writeModification = inMemoryDataTree
.takeSnapshot().newModification();
writeModification.write(newOdlProjectMapEntryPath, newProjectMapEntry);
writeModification.ready();
final DataTreeCandidate writeContributorsCandidate = inMemoryDataTree
.prepare(writeModification);
LOG.debug("*************************");
LOG.debug("Before map entry write: ");
LOG.debug("*************************");
LOG.debug(inMemoryDataTree.toString());
boolean exception = false;
try {
LeafRefValidatation.validate(writeContributorsCandidate,
rootLeafRefContext);
} catch (final LeafRefDataValidationFailedException e) {
LOG.debug("All validation errors:{}{}", NEW_LINE, e.getMessage());
assertEquals(2, e.getValidationsErrorsCount());
exception = true;
}
inMemoryDataTree.commit(writeContributorsCandidate);
LOG.debug("*************************");
LOG.debug("After map entry write: ");
LOG.debug("*************************");
LOG.debug(inMemoryDataTree.toString());
assertTrue(exception);
}
示例13: write2
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
private static void write2() {
final ContainerSchemaNode odlCon = (ContainerSchemaNode) valModule
.getDataChildByName(odl);
final ContainerSchemaNode con1Con = (ContainerSchemaNode) odlCon
.getDataChildByName(con1);
final LeafNode<String> l1Leaf = ImmutableNodes.leafNode(l1, "l1 value");
final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder = Builders
.containerBuilder(con1Con);
containerBuilder.addChild(l1Leaf);
final ContainerNode con1Node = containerBuilder.build();
final YangInstanceIdentifier con1Path = YangInstanceIdentifier.of(odl)
.node(con1);
final DataTreeModification writeModification = inMemoryDataTree
.takeSnapshot().newModification();
writeModification.write(con1Path, con1Node);
final ChoiceNode choiceNode = createChoiceNode();
final YangInstanceIdentifier choicePath = YangInstanceIdentifier
.of(odl).node(ch1);
writeModification.write(choicePath, choiceNode);
final ContainerNode con3Node = createCon3Node();
final YangInstanceIdentifier con3Path = YangInstanceIdentifier.of(odl)
.node(con3);
writeModification.write(con3Path, con3Node);
final LeafSetNode<?> leafListNode = createLeafRefLeafListNode();
final YangInstanceIdentifier leafListPath = YangInstanceIdentifier.of(
odl).node(leafrefLeafList);
writeModification.write(leafListPath, leafListNode);
writeModification.ready();
final DataTreeCandidate writeContributorsCandidate = inMemoryDataTree
.prepare(writeModification);
LOG.debug("*************************");
LOG.debug("Before write2: ");
LOG.debug("*************************");
LOG.debug(inMemoryDataTree.toString());
boolean exception = false;
try {
LeafRefValidatation.validate(writeContributorsCandidate,
rootLeafRefContext);
} catch (final LeafRefDataValidationFailedException e) {
LOG.debug("All validation errors:{}{}", NEW_LINE, e.getMessage());
assertEquals(6, e.getValidationsErrorsCount());
exception = true;
}
assertTrue(exception);
inMemoryDataTree.commit(writeContributorsCandidate);
LOG.debug("*************************");
LOG.debug("After write2: ");
LOG.debug("*************************");
LOG.debug(inMemoryDataTree.toString());
}
示例14: createBasicContributorContainer
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
private static ContainerNode createBasicContributorContainer(
final ContainerSchemaNode contributorContSchemaNode) {
final ListSchemaNode contributorListSchemaNode = (ListSchemaNode) contributorContSchemaNode
.getDataChildByName(contributor);
final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> contributorContainerBldr = Builders
.containerBuilder(contributorContSchemaNode);
final MapNode contributorMap = createBasicContributorList(contributorListSchemaNode);
contributorContainerBldr.addChild(contributorMap);
final ContainerNode contributorContainer = contributorContainerBldr
.build();
return contributorContainer;
}
示例15: testParseList
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testParseList() {
final ContainerSchemaNode interfaces = (ContainerSchemaNode) bar.getDataChildByName(QName.create(
bar.getQNameModule(), "interfaces"));
final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(bar.getQNameModule(),
"ifEntry"));
// test SchemaNode args
assertEquals(QName.create(BAR, "ifEntry"), ifEntry.getQName());
final SchemaPath expectedPath = TestUtils.createPath(true, BAR, "interfaces", "ifEntry");
assertEquals(expectedPath, ifEntry.getPath());
assertFalse(ifEntry.getDescription().isPresent());
assertFalse(ifEntry.getReference().isPresent());
assertEquals(Status.CURRENT, ifEntry.getStatus());
assertEquals(0, ifEntry.getUnknownSchemaNodes().size());
// test DataSchemaNode args
assertFalse(ifEntry.isAugmenting());
assertTrue(ifEntry.isConfiguration());
// :TODO augment to ifEntry have when condition and so in consequence
// ifEntry should be a context node ?
// assertNull(constraints.getWhenCondition());
assertEquals(0, ifEntry.getMustConstraints().size());
ElementCountConstraint constraints = ifEntry.getElementCountConstraint().get();
assertEquals(1, constraints.getMinElements().intValue());
assertEquals(11, constraints.getMaxElements().intValue());
// test AugmentationTarget args
final Set<AugmentationSchemaNode> availableAugmentations = ifEntry.getAvailableAugmentations();
assertEquals(2, availableAugmentations.size());
// test ListSchemaNode args
final List<QName> expectedKey = new ArrayList<>();
expectedKey.add(QName.create(BAR, "ifIndex"));
assertEquals(expectedKey, ifEntry.getKeyDefinition());
assertFalse(ifEntry.isUserOrdered());
// test DataNodeContainer args
assertEquals(0, ifEntry.getTypeDefinitions().size());
assertEquals(4, ifEntry.getChildNodes().size());
assertEquals(0, ifEntry.getGroupings().size());
assertEquals(0, ifEntry.getUses().size());
final LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(),
"ifIndex"));
assertEquals(ifEntry.getKeyDefinition().get(0), ifIndex.getQName());
assertTrue(ifIndex.getType() instanceof Uint32TypeDefinition);
assertEquals(Optional.of("minutes"), ifIndex.getType().getUnits());
final LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(),
"ifMtu"));
assertEquals(BaseTypes.int32Type(), ifMtu.getType());
}