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%2Fresolving%2FCompositeAttributeResolvingStrategy.java;h=f08233c8ee06ab73f855be523cd8e9c25fc1f9fe;hb=refs%2Fchanges%2F40%2F62940%2F4;hp=920b5dcd88793b0b4c428e0efda55b2959c77481;hpb=b197d75e803beac663033287d769dce62c108490;p=controller.git diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.java index 920b5dcd88..f08233c8ee 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/CompositeAttributeResolvingStrategy.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, @@ -22,14 +22,15 @@ import org.opendaylight.controller.config.util.xml.DocumentedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -class CompositeAttributeResolvingStrategy extends - AbstractAttributeResolvingStrategy { +class CompositeAttributeResolvingStrategy + extends AbstractAttributeResolvingStrategy { private final Map>> innerTypes; private final Map yangToJavaAttrMapping; private static final Logger LOG = LoggerFactory.getLogger(CompositeAttributeResolvingStrategy.class); - CompositeAttributeResolvingStrategy(final Map>> innerTypes, + CompositeAttributeResolvingStrategy( + final Map>> innerTypes, final CompositeType openType, final Map yangToJavaAttrMapping) { super(openType); this.innerTypes = innerTypes; @@ -42,7 +43,8 @@ class CompositeAttributeResolvingStrategy extends } @Override - public Optional parseAttribute(final String attrName, final Object value) throws DocumentedException { + public Optional parseAttribute(final String attrName, final Object value) + throws DocumentedException { if (value == null) { return Optional.absent(); @@ -58,7 +60,7 @@ class CompositeAttributeResolvingStrategy extends final String[] names = new String[getOpenType().keySet().size()]; final String[] descriptions = new String[getOpenType().keySet().size()]; OpenType[] itemTypes = new OpenType[names.length]; - int i = 0; + int index = 0; for (Object innerAttrName : innerTypes.keySet()) { Preconditions.checkState(innerAttrName instanceof String, "Attribute name must be string"); @@ -71,8 +73,9 @@ class CompositeAttributeResolvingStrategy extends Optional parsedInnerValue = attributeResolvingStrategy.parseAttribute(innerAttrNameStr, valueToParse); - if(attributeResolvingStrategy instanceof EnumAttributeResolvingStrategy) { - // Open type for enum contain the class name necessary for its resolution, however in a DTO + if (attributeResolvingStrategy instanceof EnumAttributeResolvingStrategy) { + // Open type for enum contain the class name necessary for its resolution, + // however in a DTO // the open type need to be just SimpleType.STRING so that JMX is happy // After the enum attribute is resolved, change its open type back to STRING openTypes.put(innerAttrNameStr, SimpleType.STRING); @@ -83,17 +86,19 @@ class CompositeAttributeResolvingStrategy extends items.put(yangToJavaAttrMapping.get(innerAttrNameStr), parsedInnerValue.isPresent() ? parsedInnerValue.get() : null); - // fill names + item types in order to reconstruct the open type for current attribute - names[i] = yangToJavaAttrMapping.get(innerAttrNameStr); - descriptions[i] = getOpenType().getDescription(names[i]); - itemTypes[i] = openTypes.get(innerAttrNameStr); - i++; + // fill names + item types in order to reconstruct the open type for current + // attribute + names[index] = yangToJavaAttrMapping.get(innerAttrNameStr); + descriptions[index] = getOpenType().getDescription(names[index]); + itemTypes[index] = openTypes.get(innerAttrNameStr); + index++; } CompositeDataSupport parsedValue; try { LOG.trace("Attribute {} with open type {}. Reconstructing open type.", attrName, getOpenType()); - setOpenType(new CompositeType(getOpenType().getTypeName(), getOpenType().getDescription(), names, descriptions, itemTypes)); + setOpenType(new CompositeType(getOpenType().getTypeName(), getOpenType().getDescription(), names, + descriptions, itemTypes)); LOG.debug("Attribute {}. Open type reconstructed to {}", attrName, getOpenType(), getOpenType()); parsedValue = new CompositeDataSupport(getOpenType(), items); } catch (final OpenDataException e) { @@ -106,10 +111,7 @@ class CompositeAttributeResolvingStrategy extends return Optional.of(parsedValue); } - protected Map preprocessValueMap(final Map valueMap) { return valueMap; } - - }