当前位置: 首页>>代码示例>>Java>>正文


Java ContainerSchemaNode.getUses方法代码示例

本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode.getUses方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerSchemaNode.getUses方法的具体用法?Java ContainerSchemaNode.getUses怎么用?Java ContainerSchemaNode.getUses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode的用法示例。


在下文中一共展示了ContainerSchemaNode.getUses方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCorrectAugment

import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testCorrectAugment() throws Exception {
    context = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());

    final Module devicesModule = TestUtils.findModule(context, "augment-module").get();

    final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
            .create(devicesModule.getQNameModule(), "my-container"));
    final Set<UsesNode> uses = devicesContainer.getUses();

    boolean augmentationIsInContainer = false;
    for (final UsesNode usesNode : uses) {
        final Set<AugmentationSchemaNode> augmentations = usesNode.getAugmentations();
        for (final AugmentationSchemaNode augmentationSchema : augmentations) {
            augmentationIsInContainer = true;
        }
    }

    assertTrue(augmentationIsInContainer);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:21,代码来源:AugmentToExtensionTest.java

示例2: testCorrectPathIntoUnsupportedTarget

import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testCorrectPathIntoUnsupportedTarget() throws Exception {

    context = TestUtils.loadModules(getClass().getResource(
            "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());

    final Module devicesModule = TestUtils.findModule(context, "augment-module").get();
    final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(
        QName.create(devicesModule.getQNameModule(), "my-container"));
    final Set<UsesNode> uses = devicesContainer.getUses();

    for (final UsesNode usesNode : uses) {
        assertTrue(usesNode.getAugmentations().isEmpty());
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:16,代码来源:AugmentToExtensionTest.java

示例3: getIdentitiesToRpcs

import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
private static Multimap<QName/* of identity */, RpcDefinition> getIdentitiesToRpcs(
        final SchemaContext schemaCtx) {
    Multimap<QName, RpcDefinition> result = HashMultimap.create();
    for (Module currentModule : schemaCtx.getModules()) {

        // Find all identities in current module for later identity->rpc mapping
        Set<QName> allIdentitiesInModule =
                Sets.newHashSet(Collections2.transform(currentModule.getIdentities(), SchemaNode::getQName));

        for (RpcDefinition rpc : currentModule.getRpcs()) {
            ContainerSchemaNode input = rpc.getInput();
            if (input != null) {
                for (UsesNode uses : input.getUses()) {

                    // Check if the rpc is config rpc by looking for input argument rpc-context-ref
                    Iterator<QName> pathFromRoot = uses.getGroupingPath().getPathFromRoot().iterator();
                    if (!pathFromRoot.hasNext() ||
                            !pathFromRoot.next().equals(ConfigConstants.RPC_CONTEXT_REF_GROUPING_QNAME)) {
                        continue;
                    }

                    for (SchemaNode refinedNode : uses.getRefines().values()) {
                        for (UnknownSchemaNode unknownSchemaNode : refinedNode
                                .getUnknownSchemaNodes()) {
                            if (ConfigConstants.RPC_CONTEXT_INSTANCE_EXTENSION_QNAME
                                    .equals(unknownSchemaNode.getNodeType())) {
                                String localIdentityName = unknownSchemaNode
                                        .getNodeParameter();
                                QName identityQName = QName.create(
                                        currentModule.getNamespace(),
                                        currentModule.getRevision(),
                                        localIdentityName);
                                Preconditions.checkArgument(allIdentitiesInModule.contains(identityQName),
                                        "Identity referenced by rpc not found. Identity: %s, rpc: %s", localIdentityName, rpc);
                                result.put(identityQName, rpc);
                            }
                        }
                    }
                }
            }
        }
    }
    return result;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:45,代码来源:RuntimeBeanEntry.java

示例4: testParseContainer

import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; //导入方法依赖的package包/类
@Test
public void testParseContainer() {
    final ContainerSchemaNode nodes = (ContainerSchemaNode) testModule
            .getDataChildByName(QName.create(testModule.getQNameModule(), "nodes"));
    // test SchemaNode args
    assertEquals(SN_NODES, nodes.getQName());
    assertEquals(SN_NODES_PATH, nodes.getPath());
    assertEquals(Optional.of("nodes collection"), nodes.getDescription());
    assertEquals(Optional.of("nodes ref"), nodes.getReference());
    assertEquals(Status.CURRENT, nodes.getStatus());
    assertEquals(0, nodes.getUnknownSchemaNodes().size());
    // test DataSchemaNode args
    assertFalse(nodes.isAugmenting());
    assertFalse(nodes.isConfiguration());

    // constraints
    assertEquals("class != 'wheel'", nodes.getWhenCondition().get().toString());
    final Collection<MustDefinition> mustConstraints = nodes.getMustConstraints();
    assertEquals(2, mustConstraints.size());

    final String must1 = "ifType != 'atm' or (ifType = 'atm' and ifMTU <= 17966 and ifMTU >= 64)";
    final String errMsg1 = "An atm MTU must be  64 .. 17966";
    final String must2 = "ifId != 0";

    boolean found1 = false;
    boolean found2 = false;
    for (final MustDefinition must : mustConstraints) {
        if (must1.equals(must.toString())) {
            found1 = true;
            assertEquals(Optional.of(errMsg1), must.getErrorMessage());
        } else if (must2.equals(must.toString())) {
            found2 = true;
            assertFalse(must.getErrorMessage().isPresent());
            assertFalse(must.getErrorAppTag().isPresent());
            assertFalse(must.getDescription().isPresent());
            assertFalse(must.getReference().isPresent());
        }
    }
    assertTrue(found1);
    assertTrue(found2);

    assertTrue(nodes.isPresenceContainer());

    // typedef
    final Set<TypeDefinition<?>> typedefs = nodes.getTypeDefinitions();
    assertEquals(1, typedefs.size());
    final TypeDefinition<?> nodesType = typedefs.iterator().next();
    final QName typedefQName = QName.create(SN, "nodes-type");
    assertEquals(typedefQName, nodesType.getQName());
    assertEquals(SN_NODES_PATH.createChild(QName.create(SN, "nodes-type")), nodesType.getPath());
    assertFalse(nodesType.getDescription().isPresent());
    assertFalse(nodesType.getReference().isPresent());
    assertEquals(Status.CURRENT, nodesType.getStatus());
    assertEquals(0, nodesType.getUnknownSchemaNodes().size());

    // child nodes
    // total size = 8: defined 6, inserted by uses 2
    assertEquals(8, nodes.getChildNodes().size());
    final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create(
        testModule.getQNameModule(), "added"));
    assertEquals(createPath("nodes", "added"), added.getPath());
    assertEquals(createPath("mytype"), added.getType().getPath());

    final ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName(QName.create(
        testModule.getQNameModule(), "links"));
    assertFalse(links.isUserOrdered());

    final Set<GroupingDefinition> groupings = nodes.getGroupings();
    assertEquals(1, groupings.size());
    final GroupingDefinition nodeGroup = groupings.iterator().next();
    final QName groupQName = QName.create(SN, "node-group");
    assertEquals(groupQName, nodeGroup.getQName());
    final SchemaPath nodeGroupPath = SN_NODES_PATH.createChild(groupQName);
    assertEquals(nodeGroupPath, nodeGroup.getPath());

    final Set<UsesNode> uses = nodes.getUses();
    assertEquals(1, uses.size());
    final UsesNode use = uses.iterator().next();
    assertEquals(nodeGroupPath, use.getGroupingPath());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:81,代码来源:YangParserSimpleTest.java


注:本文中的org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode.getUses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。