本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.Module类的典型用法代码示例。如果您正苦于以下问题:Java Module类的具体用法?Java Module怎么用?Java Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Module类属于org.opendaylight.yangtools.yang.model.api包,在下文中一共展示了Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSIE
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
private static ServiceInterfaceEntry findSIE(final String prefixAndIdentityLocalName, final Module currentModule,
final Map<QName, ServiceInterfaceEntry> qNamesToSIEs, final SchemaContext schemaContext) {
Matcher m = PREFIX_COLON_LOCAL_NAME.matcher(prefixAndIdentityLocalName);
Module foundModule;
String localSIName;
if (m.matches()) {
// if there is a prefix, look for ModuleImport with this prefix. Get
// Module from SchemaContext
String prefix = m.group(1);
ModuleImport moduleImport = findModuleImport(currentModule, prefix);
foundModule = schemaContext.findModuleByName(moduleImport.getModuleName(), moduleImport.getRevision());
checkNotNull(foundModule, format("Module not found in SchemaContext by %s", moduleImport));
localSIName = m.group(2);
} else {
foundModule = currentModule; // no prefix => SIE is in currentModule
localSIName = prefixAndIdentityLocalName;
}
QName siQName = QName.create(foundModule.getNamespace(), foundModule.getRevision(), localSIName);
ServiceInterfaceEntry sie = qNamesToSIEs.get(siQName);
checkState(sie != null, "Cannot find referenced Service Interface by " + prefixAndIdentityLocalName);
return sie;
}
示例2: getPackageName
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
/**
* Based on mapping, find longest matching key and return value plus the
* remaining part of namespace, with colons replaced by dots. Example:
* Mapping [ 'urn:opendaylight:params:xml:ns:yang:controller' :
* 'org.opendaylight.controller'] and module with namespace
* 'urn:opendaylight:params:xml:ns:yang:controller:threads:api' will result
* in 'org.opendaylight.controller.threads.api' .
*
* @throws IllegalStateException
* if there is no mapping found.
*/
public String getPackageName(final Module module) {
Entry<String, String> longestMatch = null;
int longestMatchLength = 0;
final String namespace = module.getNamespace().toString();
for (final Entry<String, String> entry : this.namespacePrefixToPackageMap
.entrySet()) {
if (namespace.startsWith(entry.getKey())
&& (entry.getKey().length() > longestMatchLength)) {
longestMatch = entry;
longestMatchLength = entry.getKey().length();
}
}
if (longestMatch != null) {
return longestMatch.getValue()
+ sanitizePackage(namespace.substring(longestMatchLength));
} else {
return BindingGeneratorUtil.moduleNamespaceToPackageName(module);
}
}
示例3: loadYangs
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
private Module loadYangs(final File testedModule, final String moduleName)
throws Exception {
final List<InputStream> yangISs = new ArrayList<>();
yangISs.addAll(getStreams("/ietf-inet-types.yang"));
yangISs.add(new FileInputStream(testedModule));
yangISs.addAll(getConfigApiYangInputStreams());
this.context = YangParserTestUtils.parseYangStreams(yangISs);
// close ISs
for (final InputStream is : yangISs) {
is.close();
}
this.namesToModules = YangModelSearchUtils.mapModulesByNames(this.context
.getModules());
this.configModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE);
final Module module = this.namesToModules.get(moduleName);
Preconditions.checkNotNull(module, "Cannot get module %s from %s",
moduleName, this.namesToModules.keySet());
return module;
}
示例4: 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);
}
示例5: 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;
}
示例6: createDefaultInstance
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public T createDefaultInstance(final FallbackConfigProvider fallback) throws ConfigXMLReaderException,
URISyntaxException, ParserConfigurationException, XMLStreamException, SAXException, IOException {
YangInstanceIdentifier yangPath = bindingSerializer.toYangInstanceIdentifier(bindingContext.appConfigPath);
LOG.debug("{}: Creating app config instance from path {}, Qname: {}", logName, yangPath,
bindingContext.bindingQName);
checkNotNull(schemaService, "%s: Could not obtain the SchemaService OSGi service", logName);
SchemaContext schemaContext = schemaService.getGlobalContext();
Module module = schemaContext.findModuleByNamespaceAndRevision(bindingContext.bindingQName.getNamespace(),
bindingContext.bindingQName.getRevision());
checkNotNull(module, "%s: Could not obtain the module schema for namespace %s, revision %s",
logName, bindingContext.bindingQName.getNamespace(), bindingContext.bindingQName.getRevision());
DataSchemaNode dataSchema = module.getDataChildByName(bindingContext.bindingQName);
checkNotNull(dataSchema, "%s: Could not obtain the schema for %s", logName, bindingContext.bindingQName);
checkCondition(bindingContext.schemaType.isAssignableFrom(dataSchema.getClass()),
"%s: Expected schema type %s for %s but actual type is %s", logName,
bindingContext.schemaType, bindingContext.bindingQName, dataSchema.getClass());
NormalizedNode<?, ?> dataNode = parsePossibleDefaultAppConfigXMLFile(schemaContext, dataSchema);
if (dataNode == null) {
dataNode = fallback.get(schemaService.getGlobalContext(), dataSchema);
}
DataObject appConfig = bindingSerializer.fromNormalizedNode(yangPath, dataNode).getValue();
// This shouldn't happen but need to handle it in case...
checkNotNull(appConfig, "%s: Could not create instance for app config binding %s", logName,
bindingContext.appConfigBindingClass);
return (T) appConfig;
}
示例7: decomposeRpcService
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
static Collection<SchemaPath> decomposeRpcService(final Class<RpcService> service,
final SchemaContext schemaContext, final Predicate<RpcRoutingStrategy> filter) {
final QNameModule moduleName = BindingReflections.getQNameModule(service);
final Module module = schemaContext.findModuleByNamespaceAndRevision(moduleName.getNamespace(),
moduleName.getRevision());
LOG.debug("Resolved service {} to module {}", service, module);
final Collection<RpcDefinition> rpcs = module.getRpcs();
final Collection<SchemaPath> ret = new ArrayList<>(rpcs.size());
for (RpcDefinition rpc : rpcs) {
final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpc);
if (filter.test(strategy)) {
ret.add(rpc.getPath());
}
}
return ret;
}
示例8: testDeviation
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
@Test
public void testDeviation() throws ReactorException {
final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
.addSource(sourceForResource("/model/bar.yang"))
.addSource(sourceForResource("/context-test/deviation-test.yang"))
.buildEffective();
final Module testModule = context.findModule("deviation-test", Revision.of("2013-02-27")).get();
final Set<Deviation> deviations = testModule.getDeviations();
assertEquals(1, deviations.size());
final Deviation dev = deviations.iterator().next();
assertEquals(Optional.of("system/user ref"), dev.getReference());
final URI expectedNS = URI.create("urn:opendaylight.bar");
final Revision expectedRev = Revision.of("2013-07-03");
final List<QName> path = new ArrayList<>();
path.add(QName.create(expectedNS, expectedRev, "interfaces"));
path.add(QName.create(expectedNS, expectedRev, "ifEntry"));
final SchemaPath expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, dev.getTargetPath());
assertEquals(DeviateKind.ADD, dev.getDeviates().iterator().next().getDeviateType());
}
示例9: writeToStatementWriter
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
static void writeToStatementWriter(final Module module, final SchemaContext ctx,
final StatementTextWriter statementWriter, final boolean emitInstantiated) {
final YangModuleWriter yangSchemaWriter = SchemaToStatementWriterAdaptor.from(statementWriter);
final Map<QName, StatementDefinition> extensions = ExtensionStatement.mapFrom(ctx.getExtensions());
if (module instanceof EffectiveStatement && !emitInstantiated) {
/*
* if module is an effective statement and we don't want to export
* instantiated statements (e.g. statements added by uses or
* augment) we can get declared form i.e. ModuleStatement and then
* use DeclaredSchemaContextEmitter
*/
new DeclaredSchemaContextEmitter(yangSchemaWriter, extensions, module.getYangVersion())
.emitModule(((EffectiveStatement<?, ?>) module).getDeclared());
} else {
/*
* if we don't have access to declared form of supplied module or we
* want to emit also instantiated statements (e.g. statements added
* by uses or augment), we use EffectiveSchemaContextEmitter.
*/
new EffectiveSchemaContextEmitter(yangSchemaWriter, extensions, module.getYangVersion(), emitInstantiated)
.emitModule(module);
}
}
示例10: testImplicitInputAndOutput
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
@Test
public void testImplicitInputAndOutput() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rpc-stmt-test/bar.yang");
assertNotNull(schemaContext);
final Module barModule = schemaContext.findModule("bar", Revision.of("2016-11-25")).get();
final Set<RpcDefinition> rpcs = barModule.getRpcs();
assertEquals(1, rpcs.size());
final RpcDefinition barRpc = rpcs.iterator().next();
final ContainerSchemaNode input = barRpc.getInput();
assertNotNull(input);
assertEquals(2, input.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) input).getDeclared().getStatementSource());
final ContainerSchemaNode output = barRpc.getOutput();
assertNotNull(output);
assertEquals(2, output.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) output).getDeclared().getStatementSource());
}
示例11: testCorrectAugment
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的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);
}
示例12: testBasicSubmodule
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
@Test
public void testBasicSubmodule() {
Module moduleConfig = mockModule(CONFIG_NAME);
Module module2 = mockModule(MODULE2_NAME);
Module module3 = mockModule(MODULE3_NAME);
Module module4 = mockModule(MODULE4_NAME);
Module module41 = mockModule(MODULE41_NAME);
mockSubmodules(module4, module41);
mockModuleImport(module2, moduleConfig, module3);
mockModuleImport(module41, moduleConfig);
SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4);
FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
moduleConfig);
assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3, module4);
}
示例13: testChainAdditionalModulesConfig
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
@Test
public void testChainAdditionalModulesConfig() {
Module moduleConfig = mockModule(CONFIG_NAME);
Module module2 = mockModule(MODULE2_NAME);
Module module3 = mockModule(MODULE3_NAME);
Module module4 = mockModule(MODULE4_NAME);
Module module5 = mockModule(MODULE5_NAME);
mockModuleImport(module2, moduleConfig);
mockModuleImport(module3, module4);
SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4, module5);
FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
Collections.singleton(module3), moduleConfig);
assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3, module4);
}
示例14: testDeclaredAugment
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
@Test
public void testDeclaredAugment() throws ReactorException {
final StatementStreamSource augmentStmtModule =
sourceForResource("/declared-statements-test/augment-declared-test.yang");
final SchemaContext schemaContext = StmtTestUtils.parseYangSources(augmentStmtModule);
assertNotNull(schemaContext);
final Module testModule = schemaContext.findModules("augment-declared-test").iterator().next();
assertNotNull(testModule);
final Set<AugmentationSchemaNode> augmentationSchemas = testModule.getAugmentations();
assertNotNull(augmentationSchemas);
assertEquals(1, augmentationSchemas.size());
final AugmentationSchemaNode augmentationSchema = augmentationSchemas.iterator().next();
final AugmentStatement augmentStatement = ((AugmentEffectiveStatement) augmentationSchema).getDeclared();
final SchemaNodeIdentifier targetNode = augmentStatement.getTargetNode();
assertNotNull(targetNode);
final Collection<? extends DataDefinitionStatement> augmentStatementDataDefinitions =
augmentStatement.getDataDefinitions();
assertNotNull(augmentStatementDataDefinitions);
assertEquals(1, augmentStatementDataDefinitions.size());
}
示例15: testAddedByUsesLeafTypeQName
import org.opendaylight.yangtools.yang.model.api.Module; //导入依赖的package包/类
@Test
public void testAddedByUsesLeafTypeQName() throws Exception {
final SchemaContext loadModules = TestUtils.loadModules(getClass().getResource("/added-by-uses-leaf-test")
.toURI());
assertEquals(2, loadModules.getModules().size());
foo = TestUtils.findModule(loadModules, "foo").get();
final Module imp = TestUtils.findModule(loadModules, "import-module").get();
final LeafSchemaNode leaf = (LeafSchemaNode) ((ContainerSchemaNode) foo.getDataChildByName(QName.create(
foo.getQNameModule(), "my-container")))
.getDataChildByName(QName.create(foo.getQNameModule(), "my-leaf"));
TypeDefinition<?> impType = null;
final Set<TypeDefinition<?>> typeDefinitions = imp.getTypeDefinitions();
for (final TypeDefinition<?> typeDefinition : typeDefinitions) {
if (typeDefinition.getQName().getLocalName().equals("imp-type")) {
impType = typeDefinition;
break;
}
}
assertNotNull(impType);
assertEquals(leaf.getType().getQName(), impType.getQName());
}