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


Java Module.getIdentities方法代码示例

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


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

示例1: assertAllIdentitiesAreExpected

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private void assertAllIdentitiesAreExpected(
        Module module,
        Map<String /* identity name */, Optional<QName>> expectedIdentitiesToBases) {
    Map<String /* identity name */, Optional<QName>> copyOfExpectedNames = new HashMap<>(
            expectedIdentitiesToBases);
    for (IdentitySchemaNode id : module.getIdentities()) {
        String localName = id.getQName().getLocalName();
        assertTrue("Unexpected identity " + localName,
                copyOfExpectedNames.containsKey(localName));
        Optional<QName> maybeExpectedBaseQName = copyOfExpectedNames
                .remove(localName);
        if (maybeExpectedBaseQName.isPresent()) {
            assertEquals("Unexpected base identity of " + localName,
                    maybeExpectedBaseQName.get(), id.getBaseIdentity()
                            .getQName());
        }
    }
    assertEquals("Expected identities not found " + copyOfExpectedNames,
            Collections.emptyMap(), copyOfExpectedNames);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:SchemaContextTest.java

示例2: transformIdentities

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static Map<String, Map<Date, IdentityMapping>> transformIdentities(final Set<Module> modules) {
    Map<String, Map<Date, IdentityMapping>> mappedIds = new HashMap<>();
    for (Module module : modules) {
        String namespace = module.getNamespace().toString();
        Map<Date, IdentityMapping> revisionsByNamespace = mappedIds.computeIfAbsent(namespace,
            k -> new HashMap<>());

        Date revision = module.getRevision();

        IdentityMapping identityMapping = revisionsByNamespace.computeIfAbsent(revision,
            k -> new IdentityMapping());

        for (IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
            identityMapping.addIdSchemaNode(identitySchemaNode);
        }

    }

    return mappedIds;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:ConfigSubsystemFacade.java

示例3: emitBodyNodes

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private void emitBodyNodes(final Module input) {

            for (final ExtensionDefinition extension : input.getExtensionSchemaNodes()) {
                emitExtension(extension);
            }
            for (final FeatureDefinition definition : input.getFeatures()) {
                emitFeature(definition);
            }
            for (final IdentitySchemaNode identity : input.getIdentities()) {
                emitIdentity(identity);
            }
            for (final Deviation deviation : input.getDeviations()) {
                emitDeviation(deviation);
            }

            emitDataNodeContainer(input);

            for (final AugmentationSchemaNode augmentation : input.getAugmentations()) {
                emitAugment(augmentation);
            }
            for (final RpcDefinition rpc : input.getRpcs()) {
                emitRpc(rpc);
            }

            emitNotifications(input.getNotifications());
        }
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:27,代码来源:SchemaContextEmitter.java

示例4: testIdentityrefWithMultipleBaseIdentities

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testIdentityrefWithMultipleBaseIdentities() throws Exception {
    final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/identityref-stmt/foo.yang");
    assertNotNull(schemaContext);

    final Module foo = schemaContext.findModule("foo", Revision.of("2017-01-11")).get();
    final Set<IdentitySchemaNode> identities = foo.getIdentities();
    assertEquals(3, identities.size());

    final LeafSchemaNode idrefLeaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
            "idref-leaf"));
    assertNotNull(idrefLeaf);

    final IdentityrefTypeDefinition idrefType = (IdentityrefTypeDefinition) idrefLeaf.getType();
    final Set<IdentitySchemaNode> referencedIdentities = idrefType.getIdentities();
    assertEquals(3, referencedIdentities.size());
    assertEquals(identities, referencedIdentities);
    assertEquals("id-a", idrefType.getIdentities().iterator().next().getQName().getLocalName());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:20,代码来源:IdentityrefStatementTest.java

示例5: testIdentity

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testIdentity() throws URISyntaxException {
    Module testModule = TestUtils.findModule(context, "config").get();
    assertNotNull(testModule);

    Set<IdentitySchemaNode> identities = testModule.getIdentities();
    assertEquals(2, identities.size());

    Iterator<IdentitySchemaNode> idIterator = identities.iterator();
    IdentitySchemaNode id = idIterator.next();

    assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
    assertTrue(id.getBaseIdentities().isEmpty());

    id = idIterator.next();
    assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
    assertTrue(id.getBaseIdentities().isEmpty());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:19,代码来源:YinFileIdentityStmtTest.java

示例6: testIdentity

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testIdentity() throws ReactorException {
    final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
            .addSources(IETF)
            .addSource(sourceForResource("/types/[email protected]"))
            .addSource(sourceForResource("/context-test/test3.yang"))
            .buildEffective();

    final Module module = context.findModule("test3", Revision.of("2013-06-18")).get();
    final Set<IdentitySchemaNode> identities = module.getIdentities();
    assertEquals(1, identities.size());

    final IdentitySchemaNode identity = identities.iterator().next();
    final QName idQName = identity.getQName();
    assertEquals(URI.create("urn:simple.demo.test3"), idQName.getNamespace());
    assertEquals(Revision.ofNullable("2013-06-18"), idQName.getRevision());
    assertEquals("pt", idQName.getLocalName());

    final IdentitySchemaNode baseIdentity = Iterables.getOnlyElement(identity.getBaseIdentities());
    final QName idBaseQName = baseIdentity.getQName();
    assertEquals(URI.create("urn:custom.types.demo"), idBaseQName.getNamespace());
    assertEquals(Revision.ofNullable("2012-04-16"), idBaseQName.getRevision());
    assertEquals("service-type", idBaseQName.getLocalName());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:25,代码来源:YangParserWithContextTest.java

示例7: mapIdentitiesByQNames

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
public Map<QName, IdentitySchemaNode> mapIdentitiesByQNames(final Module module) {
    final Map<QName, IdentitySchemaNode> result = new HashMap<>();
    for (final IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
        final QName qName = identitySchemaNode.getQName();
        Preconditions.checkArgument(
                result.containsKey(qName) == false,
                "Two identities of %s contain same qname %s",
                        module, qName);
        result.put(qName, identitySchemaNode);
    }
    return result;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:AbstractYangTest.java

示例8: testMultipleBaseIdentities

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testMultipleBaseIdentities() throws Exception {
    final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/identity-stmt/foo.yang");
    assertNotNull(schemaContext);

    final Module foo = schemaContext.findModule("foo", Revision.of("2016-12-21")).get();
    final Set<IdentitySchemaNode> identities = foo.getIdentities();
    for (final IdentitySchemaNode identity : identities) {
        if ("derived-id".equals(identity.getQName().getLocalName())) {
            final Set<IdentitySchemaNode> baseIdentities = identity.getBaseIdentities();
            assertEquals(3, baseIdentities.size());
        }
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:15,代码来源:IdentityStatementTest.java

示例9: chainedIdentityTest

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void chainedIdentityTest() throws ReactorException {
    SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
            .addSource(LEGAL_IDENTITY_MODULE3)
            .buildEffective();
    assertNotNull(result);

    Module testModule = result.findModules("legal-chained-identity-test").iterator().next();
    assertNotNull(testModule);

    Set<IdentitySchemaNode> identities = testModule.getIdentities();
    assertEquals(4, identities.size());

    Iterator<IdentitySchemaNode> identitiesIterator = identities.iterator();
    IdentitySchemaNode identity = identitiesIterator.next();
    assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"),
        is("third-identity"), is("fourth-identity")));

    identity = identitiesIterator.next();
    assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"),
        is("third-identity"), is("fourth-identity")));

    identity = identitiesIterator.next();
    assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"),
        is("third-identity"), is("fourth-identity")));

    identity = identitiesIterator.next();
    assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"),
        is("third-identity"), is("fourth-identity")));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:31,代码来源:IdentityStmtTest.java

示例10: duplicateIdentityTest

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void duplicateIdentityTest() throws ReactorException {
    SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
            .addSource(DUPLICATE_IDENTITY_MODULE)
            .buildEffective();
    assertNotNull(result);

    Module testModule = result.findModules("duplicate-identity-test").iterator().next();
    Set<IdentitySchemaNode> identities = testModule.getIdentities();
    assertEquals(1, identities.size());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:12,代码来源:IdentityStmtTest.java

示例11: testIdentity

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testIdentity() {
    Module tested = TestUtils.findModule(context, "custom-types-test").get();
    Set<IdentitySchemaNode> identities = tested.getIdentities();
    assertEquals(5, identities.size());
    IdentitySchemaNode cryptoAlg = null;
    IdentitySchemaNode cryptoBase = null;
    IdentitySchemaNode cryptoId = null;
    for (IdentitySchemaNode id : identities) {
        if (id.getQName().getLocalName().equals("crypto-alg")) {
            cryptoAlg = id;
        } else if ("crypto-base".equals(id.getQName().getLocalName())) {
            cryptoBase = id;
        } else if ("crypto-id".equals(id.getQName().getLocalName())) {
            cryptoId = id;
        }
    }
    assertNotNull(cryptoAlg);
    IdentitySchemaNode baseIdentity = Iterables.getOnlyElement(cryptoAlg.getBaseIdentities());
    assertEquals("crypto-base", baseIdentity.getQName().getLocalName());
    assertTrue(cryptoAlg.getDerivedIdentities().isEmpty());
    assertTrue(baseIdentity.getBaseIdentities().isEmpty());

    assertNotNull(cryptoBase);
    assertTrue(cryptoBase.getBaseIdentities().isEmpty());
    assertEquals(3, cryptoBase.getDerivedIdentities().size());

    assertNotNull(cryptoId);
    assertEquals(1, cryptoId.getUnknownSchemaNodes().size());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:31,代码来源:TypesResolutionTest.java

示例12: findIdentitySchemaNodeInModule

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static IdentitySchemaNode findIdentitySchemaNodeInModule(final Module module, final QName identityQName) {
    for (final IdentitySchemaNode id : module.getIdentities()) {
        if (identityQName.equals(id.getQName())) {
            return id;
        }
    }

    throw new IllegalArgumentException(String.format("Identity %s does not have a corresponding"
                + " identity schema node in the module %s.", identityQName, module));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:11,代码来源:YangFunctionContext.java

示例13: create

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
/**
 * @return Map of QNames as keys and ServiceInterfaceEntry instances as
 *         values
 */
public static Map<QName, ServiceInterfaceEntry> create(Module currentModule,
        String packageName,Map<IdentitySchemaNode, ServiceInterfaceEntry> definedSEItracker) {
    LOG.debug("Generating ServiceInterfaces from {} to package {}",
            currentModule.getNamespace(), packageName);

    Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
    Set<IdentitySchemaNode> notVisited = new HashSet<>(
            currentModule.getIdentities());
    int lastSize = notVisited.size() + 1;
    while (!notVisited.isEmpty()) {
        if (notVisited.size() == lastSize) {
            LOG.debug(
                    "Following identities will be ignored while generating ServiceInterfaces, as they are not derived from {} : {}",
                    SERVICE_TYPE_Q_NAME, notVisited);
            break;
        }
        lastSize = notVisited.size();
        for (Iterator<IdentitySchemaNode> iterator = notVisited.iterator(); iterator
                .hasNext();) {
            IdentitySchemaNode identity = iterator.next();
            ServiceInterfaceEntry created = null;
            if (identity.getBaseIdentity() == null) {
                // this can happen while loading config module, just skip
                // the identity
                continue;
            } else if (identity.getBaseIdentity().getQName()
                    .equals(SERVICE_TYPE_Q_NAME)) {
                // this is a base type
                created = new ServiceInterfaceEntry(identity, packageName, ModuleUtil.getQName(currentModule));
            } else {
                ServiceInterfaceEntry foundBase = definedSEItracker
                        .get(identity.getBaseIdentity());
                // derived type, did we convert the parent?
                if (foundBase != null) {
                    created = new ServiceInterfaceEntry(
                            Optional.of(foundBase), identity, packageName, ModuleUtil.getQName(currentModule));
                }
            }


            if (created != null) {
                created.setYangModuleName(currentModule.getName());
                // TODO how to get local name
                created.setYangModuleLocalname(identity.getQName()
                        .getLocalName());
                identitiesToSIs.put(identity, created);
                definedSEItracker.put(identity, created);
                iterator.remove();
            }
        }
    }
    // create result map
    Map<QName, ServiceInterfaceEntry> resultMap = new HashMap<>();
    for (ServiceInterfaceEntry sie : identitiesToSIs.values()) {
        resultMap.put(sie.getQName(), sie);
    }
    LOG.debug("Number of ServiceInterfaces to be generated: {}",
            resultMap.size());
    return resultMap;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:65,代码来源:ServiceInterfaceEntry.java

示例14: getIdentities

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static Set<IdentitySchemaNode> getIdentities(final SchemaContext schemaContext) {
    final Set<Module> modules = schemaContext.getModules();
    assertEquals(1, modules.size());
    final Module module = modules.iterator().next();
    return module.getIdentities();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:7,代码来源:Bug6869Test.java

示例15: identityTest

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void identityTest() throws SourceException, ReactorException,
        URISyntaxException {
    SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
            .addSources(IDENTITY_TEST)
            .buildEffective();

    assertNotNull(result);

    Module module = result.findModule("identity-test").get();
    Set<IdentitySchemaNode> identities = module.getIdentities();

    assertNotNull(identities);
    assertEquals(4, identities.size());

    IdentitySchemaNode root = null;
    IdentitySchemaNode child1 = null;
    IdentitySchemaNode child2 = null;
    IdentitySchemaNode child12 = null;
    for (IdentitySchemaNode identitySchemaNode : identities) {
        switch (identitySchemaNode.getQName().getLocalName()) {
            case "root-identity":
                root = identitySchemaNode;
                break;
            case "child-identity-1":
                child1 = identitySchemaNode;
                break;
            case "child-identity-2":
                child2 = identitySchemaNode;
                break;
            case "child-identity-1-2":
                child12 = identitySchemaNode;
                break;
            default:
                break;
        }
    }

    assertNotNull(root);
    assertNotNull(child1);
    assertNotNull(child2);
    assertNotNull(child12);

    assertTrue(root.getBaseIdentities().isEmpty());

    Set<IdentitySchemaNode> rootDerivedIdentities = root
            .getDerivedIdentities();
    assertEquals(2, rootDerivedIdentities.size());

    assertTrue(rootDerivedIdentities.contains(child1));
    assertTrue(rootDerivedIdentities.contains(child2));
    assertFalse(rootDerivedIdentities.contains(child12));
    assertFalse(child1.equals(child2));

    assertTrue(root == Iterables.getOnlyElement(child1.getBaseIdentities()));
    assertTrue(root == Iterables.getOnlyElement(child2.getBaseIdentities()));

    assertTrue(child2.getDerivedIdentities().isEmpty());

    Set<IdentitySchemaNode> child1DerivedIdentities = child1
            .getDerivedIdentities();
    assertEquals(1, child1DerivedIdentities.size());
    assertTrue(child1DerivedIdentities.contains(child12));
    assertFalse(child1DerivedIdentities.contains(child1));

    assertTrue(child1 == Iterables.getOnlyElement(child12.getBaseIdentities()));
    assertTrue(child12 == child1DerivedIdentities.iterator().next());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:69,代码来源:EffectiveIdentityTest.java


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