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%2Fattributes%2Fresolving%2FArrayAttributeResolvingStrategy.java;h=7f085978a0f9a31c4157c029c18f805448efdd2c;hp=5daf5a42a941c91a13823082e0fcb7790438a7fa;hb=d266f4384d4850af9049d7cddd2bbac8f75ba61e;hpb=b197d75e803beac663033287d769dce62c108490 diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ArrayAttributeResolvingStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ArrayAttributeResolvingStrategy.java index 5daf5a42a9..7f085978a0 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ArrayAttributeResolvingStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ArrayAttributeResolvingStrategy.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, @@ -21,7 +21,7 @@ import org.opendaylight.controller.config.util.xml.DocumentedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -final class ArrayAttributeResolvingStrategy extends AbstractAttributeResolvingStrategy> { +public final class ArrayAttributeResolvingStrategy extends AbstractAttributeResolvingStrategy> { private final AttributeResolvingStrategy> innerTypeResolvingStrategy; @@ -50,8 +50,8 @@ final class ArrayAttributeResolvingStrategy extends AbstractAttributeResolvingSt try { innerTypeClass = Class.forName(getOpenType().getElementOpenType().getClassName()); } catch (final ClassNotFoundException e) { - throw new IllegalStateException("Unable to locate class for " - + getOpenType().getElementOpenType().getClassName(), e); + throw new IllegalStateException( + "Unable to locate class for " + getOpenType().getElementOpenType().getClassName(), e); } } @@ -64,21 +64,21 @@ final class ArrayAttributeResolvingStrategy extends AbstractAttributeResolvingSt parsedArray = Array.newInstance(innerTypeClass, valueList.size()); } - int i = 0; + int index = 0; for (Object innerValue : valueList) { - Optional parsedElement = innerTypeResolvingStrategy.parseAttribute(attrName + "_" + i, innerValue); - if (!parsedElement.isPresent()){ + Optional parsedElement = innerTypeResolvingStrategy.parseAttribute(attrName + "_" + index, innerValue); + if (!parsedElement.isPresent()) { continue; } - Array.set(parsedArray, i, parsedElement.get()); - i++; + Array.set(parsedArray, index, parsedElement.get()); + index++; } // Rebuild open type. Underlying composite types might have changed if (innerTypeResolvingStrategy.getOpenType() instanceof CompositeType) { try { - final ArrayType openType = - new ArrayType<>(getOpenType().getDimension(), innerTypeResolvingStrategy.getOpenType()); + final ArrayType openType = new ArrayType<>(getOpenType().getDimension(), + innerTypeResolvingStrategy.getOpenType()); setOpenType(openType); } catch (final OpenDataException e) { throw new IllegalStateException("An error occurred during restoration of array type " + this @@ -106,7 +106,7 @@ final class ArrayAttributeResolvingStrategy extends AbstractAttributeResolvingSt private static Class getPrimitiveType(final Class innerTypeClass) { try { return (Class) innerTypeClass.getField("TYPE").get(null); - } catch (final Exception e) { + } catch (final IllegalAccessException | IllegalArgumentException | NoSuchFieldException e) { throw new IllegalStateException("Unable to determine primitive type to " + innerTypeClass); } }