X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager-facade-xml%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Ffacade%2Fxml%2Fmapping%2Fattributes%2Fmapping%2FObjectMapper.java;h=36fd085da60932f7acaebc3edf065dad2949b1f4;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hp=65a3367a6b39af8e651763b914c77a0e89743daf;hpb=23fe9ca678ada6263fec5dd996f4025e4a32fcf5;p=controller.git diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/mapping/ObjectMapper.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/mapping/ObjectMapper.java index 65a3367a6b..36fd085da6 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/mapping/ObjectMapper.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/mapping/ObjectMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2015, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -28,49 +28,50 @@ public class ObjectMapper extends AttributeIfcSwitchStatement>> prepareMapping( - Map configDefinition, EnumResolver enumResolver) { + final Map configDefinition, final EnumResolver enumResolver) { this.enumResolver = Preconditions.checkNotNull(enumResolver); Map>> strategies = Maps.newHashMap(); for (Entry attrEntry : configDefinition.entrySet()) { strategies.put(attrEntry.getKey(), prepareStrategy(attrEntry.getValue())); } - return strategies; } - public AttributeMappingStrategy> prepareStrategy(AttributeIfc attributeIfc) { + public AttributeMappingStrategy> prepareStrategy(final AttributeIfc attributeIfc) { - if(attributeIfc instanceof DependencyAttribute) { - namespaceOfDepAttr = ((DependencyAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString(); + if (attributeIfc instanceof DependencyAttribute) { + namespaceOfDepAttr = ((DependencyAttribute) attributeIfc).getDependency().getSie().getQName().getNamespace() + .toString(); } else if (attributeIfc instanceof ListDependenciesAttribute) { - namespaceOfDepAttr = ((ListDependenciesAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString(); + namespaceOfDepAttr = ((ListDependenciesAttribute) attributeIfc).getDependency().getSie().getQName() + .getNamespace().toString(); } - return switchAttribute(attributeIfc); } - private Map createJmxToYangMapping(TOAttribute attributeIfc) { + private Map createJmxToYangMapping(final TOAttribute attributeIfc) { Map retVal = Maps.newHashMap(); for (Entry entry : attributeIfc.getJmxPropertiesToTypesMap().entrySet()) { - retVal.put(entry.getKey(), (entry.getValue()).getAttributeYangName()); + retVal.put(entry.getKey(), entry.getValue().getAttributeYangName()); } return retVal; } @Override - protected AttributeMappingStrategy> caseJavaSimpleAttribute(SimpleType openType) { + protected AttributeMappingStrategy> caseJavaSimpleAttribute(final SimpleType openType) { return new SimpleAttributeMappingStrategy(openType); } @Override protected AttributeMappingStrategy> caseJavaEnumAttribute(final OpenType openType) { - return new EnumAttributeMappingStrategy(((CompositeType) openType), enumResolver); + return new EnumAttributeMappingStrategy((CompositeType) openType, enumResolver); } @Override - protected AttributeMappingStrategy> caseJavaArrayAttribute(ArrayType openType) { + protected AttributeMappingStrategy> caseJavaArrayAttribute(final ArrayType openType) { AttributeMappingStrategy> innerStrategy = new SimpleAttributeMappingStrategy( (SimpleType) openType.getElementOpenType()); @@ -78,7 +79,8 @@ public class ObjectMapper extends AttributeIfcSwitchStatement> caseJavaCompositeAttribute(CompositeType openType) { + protected AttributeMappingStrategy> caseJavaCompositeAttribute( + final CompositeType openType) { Map>> innerStrategies = Maps.newHashMap(); Map attributeMapping = Maps.newHashMap(); @@ -88,12 +90,11 @@ public class ObjectMapper extends AttributeIfcSwitchStatement> caseJavaUnionAttribute(OpenType openType) { + protected AttributeMappingStrategy> caseJavaUnionAttribute(final OpenType openType) { Map>> innerStrategies = Maps.newHashMap(); Map attributeMapping = Maps.newHashMap(); @@ -104,44 +105,42 @@ public class ObjectMapper extends AttributeIfcSwitchStatement> caseDependencyAttribute( - SimpleType openType) { + protected AttributeMappingStrategy> caseDependencyAttribute(final SimpleType openType) { return new ObjectNameAttributeMappingStrategy(openType, namespaceOfDepAttr); } @Override - protected AttributeMappingStrategy> caseTOAttribute(CompositeType openType) { + protected AttributeMappingStrategy> caseTOAttribute(final CompositeType openType) { Map>> innerStrategies = Maps.newHashMap(); Preconditions.checkState(getLastAttribute() instanceof TOAttribute); TOAttribute lastTO = (TOAttribute) getLastAttribute(); - for (Entry innerAttrEntry : ((TOAttribute)getLastAttribute()).getJmxPropertiesToTypesMap().entrySet()) { + for (Entry innerAttrEntry : ((TOAttribute) getLastAttribute()) + .getJmxPropertiesToTypesMap().entrySet()) { innerStrategies.put(innerAttrEntry.getKey(), prepareStrategy(innerAttrEntry.getValue())); } - return new CompositeAttributeMappingStrategy(openType, innerStrategies, - createJmxToYangMapping(lastTO)); + return new CompositeAttributeMappingStrategy(openType, innerStrategies, createJmxToYangMapping(lastTO)); } @Override - protected AttributeMappingStrategy> caseListAttribute(ArrayType openType) { + protected AttributeMappingStrategy> caseListAttribute(final ArrayType openType) { Preconditions.checkState(getLastAttribute() instanceof ListAttribute); return new ArrayAttributeMappingStrategy(openType, prepareStrategy(((ListAttribute) getLastAttribute()).getInnerAttribute())); } @Override - protected AttributeMappingStrategy> caseListDependeciesAttribute(ArrayType openType) { + protected AttributeMappingStrategy> caseListDependeciesAttribute( + final ArrayType openType) { Preconditions.checkState(getLastAttribute() instanceof ListDependenciesAttribute); return new ArrayAttributeMappingStrategy(openType, caseDependencyAttribute(SimpleType.OBJECTNAME)); } - }