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


Java Module.getImports方法代码示例

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


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

示例1: create

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
/**
 * Create a prefix {@link Converter} for {@link XPathExpressionException} defined in a particular YANG
 * {@link Module} .Instantiation requires establishing how a module's imports are mapped to actual modules
 * and their namespaces. This information is cached and used for improved lookups.
 *
 * @param ctx A SchemaContext
 * @param module Module in which the XPath is defined
 * @return A new Converter
 */
public static @Nonnull Converter<String, QNameModule> create(final SchemaContext ctx, final Module module) {
    // Always check for null ctx
    requireNonNull(ctx, "Schema context may not be null");

    // Use immutable map builder for detection of duplicates (which should never occur)
    final Builder<String, QNameModule> b = ImmutableBiMap.builder();
    b.put(module.getPrefix(), module.getQNameModule());

    for (ModuleImport i : module.getImports()) {
        final Optional<Module> mod = ctx.findModule(i.getModuleName(), i.getRevision());
        checkArgument(mod.isPresent(), "Unsatisfied import of %s by module %s", i, module);

        b.put(i.getPrefix(), mod.get().getQNameModule());
    }

    return Maps.asConverter(b.build());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:27,代码来源:PrefixConverters.java

示例2: checkInterfacesModuleSimpleTest

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static void checkInterfacesModuleSimpleTest(final SchemaContext context,
        final Revision rev20100924, final QName dateTimeTypeDef20100924) {
    URI interfacesNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-interfaces");
    Revision rev20121115 = Revision.of("2012-11-15");
    final QNameModule interfacesNS20121115 = QNameModule.create(interfacesNS, rev20121115);
    QName lastChange = QName.create(interfacesNS20121115, "last-change");

    Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get();
    DataSchemaNode leafLastChange = interfacesModule20121115.getDataChildByName(lastChange);
    assertNotNull(leafLastChange);

    assertTrue(leafLastChange instanceof LeafSchemaNode);
    QName lastChangeTypeQName = ((LeafSchemaNode) leafLastChange).getType().getQName();
    assertEquals(dateTimeTypeDef20100924, lastChangeTypeQName);

    Set<ModuleImport> imports = interfacesModule20121115.getImports();
    assertEquals(1, imports.size());
    ModuleImport interfacesImport = imports.iterator().next();
    assertEquals("ietf-yang-types", interfacesImport.getModuleName());
    assertEquals(Optional.of(rev20100924), interfacesImport.getRevision());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:22,代码来源:MoreRevisionsTest.java

示例3: checkNetconfMonitoringModuleSimpleTest

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static void checkNetconfMonitoringModuleSimpleTest(final SchemaContext context,
        final Revision rev20130715, final QName dateTimeTypeDef20130715) {
    URI monitoringNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring");
    final QNameModule monitoring19700101 = QNameModule.create(monitoringNS);
    QName lockedTime = QName.create(monitoring19700101, "locked-time");

    Module monitoringModule19700101 = context.findModule("ietf-netconf-monitoring").get();
    DataSchemaNode leafLockedTime = monitoringModule19700101.getDataChildByName(lockedTime);
    assertNotNull(leafLockedTime);

    assertTrue(leafLockedTime instanceof LeafSchemaNode);
    QName lockedTimeTypeQName = ((LeafSchemaNode) leafLockedTime).getType().getQName();
    assertEquals(dateTimeTypeDef20130715, lockedTimeTypeQName);

    Set<ModuleImport> imports = monitoringModule19700101.getImports();
    assertEquals(1, imports.size());
    ModuleImport monitoringImport = imports.iterator().next();
    assertEquals("ietf-yang-types", monitoringImport.getModuleName());
    assertEquals(Optional.of(rev20130715), monitoringImport.getRevision());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:21,代码来源:MoreRevisionsTest.java

示例4: testImport

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

    Set<ModuleImport> imports = testModule.getImports();
    assertEquals(2, imports.size());

    Iterator<ModuleImport> importsIterator = imports.iterator();
    ModuleImport moduleImport = importsIterator.next();

    assertThat(moduleImport.getModuleName(), anyOf(is("ietf-yang-types"), is("ietf-inet-types")));
    assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));

    moduleImport = importsIterator.next();
    assertThat(moduleImport.getModuleName(), anyOf(is("ietf-yang-types"), is("ietf-inet-types")));
    assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:19,代码来源:YinFileImportStmtTest.java

示例5: test

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug9005");
    assertNotNull(context);

    final Module foo = context.findModule("foo", Revision.of("2017-07-07")).get();

    final Set<ModuleImport> imports = foo.getImports();
    assertEquals(1, imports.size());
    final ModuleImport imp1 = imports.iterator().next();
    assertEquals("bar-2", imp1.getModuleName());
    assertEquals("bar", imp1.getPrefix());
    assertEquals(Revision.ofNullable("2000-01-02"), imp1.getRevision());

    final Set<Module> submodules = foo.getSubmodules();
    assertEquals(1, submodules.size());
    final Module submodule = submodules.iterator().next();
    final Set<ModuleImport> subImports = submodule.getImports();

    assertEquals(1, subImports.size());
    final ModuleImport subImp1 = subImports.iterator().next();
    assertEquals("bar-1", subImp1.getModuleName());
    assertEquals("bar", subImp1.getPrefix());
    assertEquals(Revision.ofNullable("2000-01-01"), subImp1.getRevision());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:26,代码来源:Bug9005Test.java

示例6: test

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug8597");
    assertNotNull(context);

    final Module foo = context.findModule("foo").get();
    final Set<ModuleImport> imports = foo.getImports();

    for (final ModuleImport moduleImport : imports) {
        switch (moduleImport.getModuleName()) {
            case "bar":
                assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision());
                assertEquals(Optional.of("bar-ref"), moduleImport.getReference());
                assertEquals(Optional.of("bar-desc"), moduleImport.getDescription());
                break;
            case "baz":
                assertEquals(Revision.ofNullable("2010-10-10"), moduleImport.getRevision());
                assertEquals(Optional.of("baz-ref"), moduleImport.getReference());
                assertEquals(Optional.of("baz-desc"), moduleImport.getDescription());
                break;
            default:
                fail("Module 'foo' should only contains import of module 'bar' and 'baz'");
        }
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:26,代码来源:Bug8597Test.java

示例7: createQName

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private QName createQName(final String prefix, final String localName) {
    final Module module = schemaContext.findModule(schemaNode.getQName().getModule()).get();
    if (prefix.isEmpty() || module.getPrefix().equals(prefix)) {
        return QName.create(module.getQNameModule(), localName);
    }

    for (final ModuleImport moduleImport : module.getImports()) {
        if (prefix.equals(moduleImport.getPrefix())) {
            final Module importedModule = schemaContext.findModule(moduleImport.getModuleName(),
                    moduleImport.getRevision()).get();
            return QName.create(importedModule.getQNameModule(),localName);
        }
    }

    throw new IllegalArgumentException(String.format("Failed to lookup a module for prefix %s", prefix));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:17,代码来源:LeafrefXPathStringParsingPathArgumentBuilder.java

示例8: findModuleImport

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static ModuleImport findModuleImport(final Module module, final String prefix) {
    for (ModuleImport moduleImport : module.getImports()) {
        if (moduleImport.getPrefix().equals(prefix)) {
            return moduleImport;
        }
    }
    throw new IllegalStateException(format("Import not found with prefix %s in %s", prefix, module));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:ModuleMXBeanEntryBuilder.java

示例9: getConfigModulePrefixFromImport

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static String getConfigModulePrefixFromImport(final Module currentModule) {
    for (ModuleImport currentImport : currentModule.getImports()) {
        if (currentImport.getModuleName().equals(ConfigConstants.CONFIG_MODULE)) {
            return currentImport.getPrefix();
        }
    }
    throw new IllegalArgumentException("Cannot find import " + ConfigConstants.CONFIG_MODULE + " in "
            + currentModule);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:ModuleMXBeanEntryBuilder.java

示例10: prefixToNamespace

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static Map<String, URI> prefixToNamespace(final SchemaContext ctx, final Module module) {
    final BiMap<String, URI> prefixMap = HashBiMap.create(module.getImports().size() + 1);
    prefixMap.put(module.getPrefix(), module.getNamespace());
    for (final ModuleImport imp : module.getImports()) {
        final String prefix = imp.getPrefix();
        final URI namespace = getModuleNamespace(ctx, imp.getModuleName());
        prefixMap.put(prefix, namespace);
    }
    return prefixMap;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:11,代码来源:YinExportUtils.java

示例11: emitLinkageNodes

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private void emitLinkageNodes(final Module input) {
    for (final ModuleImport importNode : input.getImports()) {
        emitImport(importNode);
    }
    /*
     * FIXME: BUG-2444: Emit include statements
     */
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:9,代码来源:SchemaContextEmitter.java

示例12: checkInterfacesModuleFullTest

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static void checkInterfacesModuleFullTest(final SchemaContext context, final Revision rev20100924,
        final QName dateTimeTypeDef20100924) {
    Revision rev20121115 = Revision.of("2012-11-15");

    Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get();
    Set<ModuleImport> imports = interfacesModule20121115.getImports();
    assertEquals(1, imports.size());
    ModuleImport interfacesImport = imports.iterator().next();
    assertEquals("ietf-yang-types", interfacesImport.getModuleName());
    assertEquals(Optional.of(rev20100924), interfacesImport.getRevision());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:12,代码来源:MoreRevisionsTest.java

示例13: checkModuleDependency

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private boolean checkModuleDependency(final Module module, final Collection<ModuleId> rootModules) {

        for (ModuleId rootModule : rootModules) {

            if (rootModule.equals(new ModuleId(module.getName(), module.getRevision()))) {
                return true;
            }

            //handling/checking imports regarding root modules
            for (ModuleImport moduleImport : module.getImports()) {

                if (moduleImport.getModuleName().equals(rootModule.getName())) {

                    if (moduleImport.getRevision().isPresent()
                            && !moduleImport.getRevision().equals(rootModule.getRev())) {
                        return false;
                    }

                    return true;
                }
            }

            //submodules handling
            for (Module moduleSub : module.getSubmodules()) {
                return checkModuleDependency(moduleSub, rootModules);
            }
        }

        return false;
    }
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:31,代码来源:FilteringSchemaContextProxy.java

示例14: testParsingImportPrefixIdentityTestModule

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testParsingImportPrefixIdentityTestModule() throws Exception {
    Module module = TestUtils.findModule(TestUtils.loadModules(getClass().getResource("/identity/import").toURI()),
        "prefiximportidentitytest").get();
    Set<ModuleImport> imports = module.getImports();
    assertEquals(imports.size(), 1);
    ModuleImport dummy = TestUtils.findImport(imports, "dummy");
    assertNotEquals(dummy.getPrefix(), module.getPrefix());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:10,代码来源:YangParserIdentityTest.java

示例15: findImportedModule

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
public static Module findImportedModule(final SchemaContext context, final Module rootModule,
        final String importedModuleName) {
    ModuleImport requestedModuleImport = null;
    final Set<ModuleImport> rootImports = rootModule.getImports();
    for (final ModuleImport moduleImport : rootImports) {
        if (moduleImport.getModuleName().equals(importedModuleName)) {
            requestedModuleImport = moduleImport;
            break;
        }
    }

    return context.findModule(requestedModuleImport.getModuleName(), requestedModuleImport.getRevision())
            .orElse(null);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:15,代码来源:StmtTestUtils.java


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