Search in sources :

Example 1 with ModuleImport

use of org.opendaylight.yangtools.yang.model.api.ModuleImport in project controller by opendaylight.

the class ModuleMXBeanEntryBuilder method findSIE.

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.findModule(moduleImport.getModuleName(), moduleImport.getRevision()).orElse(null);
        checkNotNull(foundModule, format("Module not found in SchemaContext by %s", moduleImport));
        localSIName = m.group(2);
    } else {
        // no prefix => SIE is in currentModule
        foundModule = 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;
}
Also used : Matcher(java.util.regex.Matcher) QName(org.opendaylight.yangtools.yang.common.QName) ConfigConstants.createConfigQName(org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName) ModuleImport(org.opendaylight.yangtools.yang.model.api.ModuleImport) Module(org.opendaylight.yangtools.yang.model.api.Module)

Aggregations

Matcher (java.util.regex.Matcher)1 ConfigConstants.createConfigQName (org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName)1 QName (org.opendaylight.yangtools.yang.common.QName)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 ModuleImport (org.opendaylight.yangtools.yang.model.api.ModuleImport)1