X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager-facade-xml%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Ffacade%2Fxml%2Fmapping%2Fconfig%2FConfig.java;h=21b74da6cd23dd2a79c7c6422b461e1e4b428171;hp=10602ce7e5011e42bff511430bd46353c4565cde;hb=e331fa568ee0b7a33ec451a104123bcbf7d86e78;hpb=cbcc2b61265e903959f11d44c292771e76b3926e diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Config.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Config.java index 10602ce7e5..21b74da6cd 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Config.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Config.java @@ -44,18 +44,18 @@ public class Config { private final EnumResolver enumResolver; - public Config(Map> moduleConfigs, final EnumResolver enumResolver) { + public Config(final Map> moduleConfigs, final EnumResolver enumResolver) { this(moduleConfigs, Collections.>emptyMap(), enumResolver); } - public Config(Map> moduleConfigs, Map> identityMap, final EnumResolver enumResolver) { + public Config(final Map> moduleConfigs, final Map> identityMap, final EnumResolver enumResolver) { this.moduleConfigs = moduleConfigs; this.identityMap = identityMap; this.enumResolver = enumResolver; } - public static Map>> getMappedInstances(Set instancesToMap, - Map> configs) { + public static Map>> getMappedInstances(final Set instancesToMap, + final Map> configs) { Multimap moduleToInstances = mapInstancesToModules(instancesToMap); Map>> retVal = Maps.newLinkedHashMap(); @@ -85,7 +85,7 @@ public class Config { return retVal; } - private static Multimap mapInstancesToModules(Set instancesToMap) { + private static Multimap mapInstancesToModules(final Set instancesToMap) { Multimap retVal = HashMultimap.create(); for (ObjectName objectName : instancesToMap) { @@ -95,8 +95,8 @@ public class Config { return retVal; } - public Element toXml(Set instancesToMap, Optional maybeNamespace, Document document, - Element dataElement, ServiceRegistryWrapper serviceTracker) { + public Element toXml(final Set instancesToMap, final Optional maybeNamespace, final Document document, + final Element dataElement, final ServiceRegistryWrapper serviceTracker) { Map>> moduleToInstances = getMappedInstances(instancesToMap, moduleConfigs); @@ -129,8 +129,8 @@ public class Config { return dataElement; } - public Element moduleToXml(String moduleNamespace, String factoryName, String instanceName, - ObjectName instanceON, Document document) { + public Element moduleToXml(final String moduleNamespace, final String factoryName, final String instanceName, + final ObjectName instanceON, final Document document) { ModuleConfig moduleConfig = getModuleMapping(moduleNamespace, instanceName, factoryName); return moduleConfig.toXml(instanceON, document, moduleNamespace, enumResolver); } @@ -139,7 +139,7 @@ public class Config { // TODO refactor, replace Map->Multimap with e.g. ConfigElementResolved // class - public Map> fromXmlModulesResolved(XmlElement xml, EditStrategyType defaultEditStrategyType, ServiceRegistryWrapper serviceTracker) throws DocumentedException { + public Map> fromXmlModulesResolved(final XmlElement xml, final EditStrategyType defaultEditStrategyType, final ServiceRegistryWrapper serviceTracker) throws DocumentedException { Optional modulesElement = getModulesElement(xml); List moduleElements = getModulesElementList(modulesElement); @@ -148,7 +148,7 @@ public class Config { for (XmlElement moduleElement : moduleElements) { ResolvingStrategy resolvingStrategy = new ResolvingStrategy() { @Override - public ModuleElementResolved resolveElement(ModuleConfig moduleMapping, XmlElement moduleElement, ServiceRegistryWrapper serviceTracker, String instanceName, String moduleNamespace, EditStrategyType defaultStrategy) throws DocumentedException { + public ModuleElementResolved resolveElement(final ModuleConfig moduleMapping, final XmlElement moduleElement, final ServiceRegistryWrapper serviceTracker, final String instanceName, final String moduleNamespace, final EditStrategyType defaultStrategy) throws DocumentedException { return moduleMapping.fromXml(moduleElement, serviceTracker, instanceName, moduleNamespace, defaultStrategy, identityMap, enumResolver); } @@ -162,8 +162,8 @@ public class Config { /** * return a map containing namespace -> moduleName -> instanceName map. Attribute parsing is omitted. */ - public Map> fromXmlModulesMap(XmlElement xml, - EditStrategyType defaultEditStrategyType, ServiceRegistryWrapper serviceTracker) throws DocumentedException { + public Map> fromXmlModulesMap(final XmlElement xml, + final EditStrategyType defaultEditStrategyType, final ServiceRegistryWrapper serviceTracker) throws DocumentedException { Optional modulesElement = getModulesElement(xml); List moduleElements = getModulesElementList(modulesElement); @@ -172,9 +172,9 @@ public class Config { for (XmlElement moduleElement : moduleElements) { ResolvingStrategy resolvingStrategy = new ResolvingStrategy() { @Override - public ModuleElementDefinition resolveElement(ModuleConfig moduleMapping, XmlElement moduleElement, - ServiceRegistryWrapper serviceTracker, String instanceName, String moduleNamespace, - EditStrategyType defaultStrategy) { + public ModuleElementDefinition resolveElement(final ModuleConfig moduleMapping, final XmlElement moduleElement, + final ServiceRegistryWrapper serviceTracker, final String instanceName, final String moduleNamespace, + final EditStrategyType defaultStrategy) { // TODO: add check for conflicts between global and local // edit strategy String perInstanceEditStrategy = moduleElement.getAttribute(XmlMappingConstants.OPERATION_ATTR_KEY, @@ -188,12 +188,12 @@ public class Config { return retVal; } - private static Optional getModulesElement(XmlElement xml) { + private static Optional getModulesElement(final XmlElement xml) { return xml.getOnlyChildElementOptionally(XmlMappingConstants.MODULES_KEY, XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG); } - private List getModulesElementList(Optional modulesElement) throws DocumentedException { + private List getModulesElementList(final Optional modulesElement) throws DocumentedException { List moduleElements; if (modulesElement.isPresent()) { @@ -205,8 +205,8 @@ public class Config { return moduleElements; } - private void resolveModule(Map> retVal, ServiceRegistryWrapper serviceTracker, - XmlElement moduleElement, EditStrategyType defaultStrategy, ResolvingStrategy resolvingStrategy) throws DocumentedException { + private void resolveModule(final Map> retVal, final ServiceRegistryWrapper serviceTracker, + final XmlElement moduleElement, final EditStrategyType defaultStrategy, final ResolvingStrategy resolvingStrategy) throws DocumentedException { XmlElement typeElement = null; typeElement = moduleElement.getOnlyChildElementWithSameNamespace(XmlMappingConstants.TYPE_KEY); Entry prefixToNamespace = typeElement.findNamespaceOfTextContent(); @@ -232,7 +232,7 @@ public class Config { innerMap.put(factoryName, resolvedElement); } - public Services fromXmlServices(XmlElement xml) throws DocumentedException { + public Services fromXmlServices(final XmlElement xml) throws DocumentedException { Optional servicesElement = getServicesElement(xml); Services services; @@ -245,12 +245,12 @@ public class Config { return services; } - private static Optional getServicesElement(XmlElement xml) { + private static Optional getServicesElement(final XmlElement xml) { return xml.getOnlyChildElementOptionally(XmlMappingConstants.SERVICES_KEY, XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG); } - public static void checkUnrecognisedChildren(XmlElement parent) throws DocumentedException { + public static void checkUnrecognisedChildren(final XmlElement parent) throws DocumentedException { Optional servicesOpt = getServicesElement(parent); Optional modulesOpt = getModulesElement(parent); @@ -265,7 +265,7 @@ public class Config { parent.checkUnrecognisedElements(recognised); } - private String getFactoryName(String factoryNameWithPrefix, String prefixOrEmptyString) { + private String getFactoryName(final String factoryNameWithPrefix, final String prefixOrEmptyString) { checkState( factoryNameWithPrefix.startsWith(prefixOrEmptyString), String.format("Internal error: text " + "content '%s' of type node does not start with prefix '%s'", @@ -280,7 +280,7 @@ public class Config { return factoryNameWithPrefix.substring(factoryNameAfterPrefixIndex); } - private ModuleConfig getModuleMapping(String moduleNamespace, String instanceName, String factoryName) { + private ModuleConfig getModuleMapping(final String moduleNamespace, final String instanceName, final String factoryName) { Map mappingsFromNamespace = moduleConfigs.get(moduleNamespace); Preconditions.checkNotNull(mappingsFromNamespace,