Search in sources :

Example 1 with AugmentationSchemaNode

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

the class ModuleMXBeanEntryBuilder method build.

public Map<String, ModuleMXBeanEntry> build() {
    LOG.debug("Generating ModuleMXBeans of {} to package {}", currentModule.getNamespace(), packageName);
    String configModulePrefix;
    try {
        configModulePrefix = getConfigModulePrefixFromImport(currentModule);
    } catch (IllegalArgumentException e) {
        // this currentModule does not import config currentModule
        return Collections.emptyMap();
    }
    // get identities of base config:currentModule-type
    Map<String, IdentitySchemaNode> moduleIdentities = getIdentityMap();
    Map<String, QName> uniqueGeneratedClassesNames = new HashMap<>();
    // each currentModule name should have an augmentation defined
    Map<String, IdentitySchemaNode> unaugmentedModuleIdentities = new HashMap<>(moduleIdentities);
    Map<String, ModuleMXBeanEntry> result = new HashMap<>();
    for (AugmentationSchemaNode augmentation : currentModule.getAugmentations()) {
        Collection<DataSchemaNode> childNodes = augmentation.getChildNodes();
        if (areAllChildrenCaseSchemaNodes(childNodes)) {
            for (CaseSchemaNode childCase : castChildNodesToChoiceCases(childNodes)) {
                // TODO refactor, extract to standalone builder class
                processCaseSchemaNode(result, uniqueGeneratedClassesNames, configModulePrefix, moduleIdentities, unaugmentedModuleIdentities, augmentation, childCase);
            }
        }
    // skip if child nodes are not all cases
    }
    // clean up nulls
    cleanUpNulls(result);
    // check attributes name uniqueness
    checkAttributeNamesUniqueness(uniqueGeneratedClassesNames, result);
    checkUnaugumentedIdentities(unaugmentedModuleIdentities);
    LOG.debug("Number of ModuleMXBeans to be generated: {}", result.size());
    return result;
}
Also used : AugmentationSchemaNode(org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode) HashMap(java.util.HashMap) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) QName(org.opendaylight.yangtools.yang.common.QName) ConfigConstants.createConfigQName(org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName) IdentitySchemaNode(org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode) CaseSchemaNode(org.opendaylight.yangtools.yang.model.api.CaseSchemaNode)

Aggregations

HashMap (java.util.HashMap)1 ConfigConstants.createConfigQName (org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName)1 QName (org.opendaylight.yangtools.yang.common.QName)1 AugmentationSchemaNode (org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode)1 CaseSchemaNode (org.opendaylight.yangtools.yang.model.api.CaseSchemaNode)1 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)1 IdentitySchemaNode (org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)1