package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving;
import com.google.common.base.Optional;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import java.lang.reflect.Array;
+import java.util.List;
import javax.management.openmbean.ArrayType;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
-import java.lang.reflect.Array;
-import java.util.List;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
final class ArrayAttributeResolvingStrategy extends AbstractAttributeResolvingStrategy<Object, ArrayType<?>> {
private final AttributeResolvingStrategy<?, ? extends OpenType<?>> innerTypeResolvingStrategy;
- private static final Logger logger = LoggerFactory.getLogger(ArrayAttributeResolvingStrategy.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ArrayAttributeResolvingStrategy.class);
public ArrayAttributeResolvingStrategy(AttributeResolvingStrategy<?, ? extends OpenType<?>> innerTypeResolved,
ArrayType<?> openType) {
i++;
}
- logger.debug("Attribute {} : {} parsed to type {} as {}", attrName, value, getOpenType(),
+ // Rebuild open type. Underlying composite types might have changed
+ if (innerTypeResolvingStrategy.getOpenType() instanceof CompositeType) {
+ try {
+ final ArrayType<?> openType = new ArrayType<Object>(getOpenType().getDimension(), innerTypeResolvingStrategy.getOpenType());
+ setOpenType(openType);
+ } catch (OpenDataException e) {
+ throw new IllegalStateException("An error occurred during restoration of array type " + this
+ + " for attribute " + attrName + " from value " + value, e);
+ }
+ }
+
+ LOG.debug("Attribute {} : {} parsed to type {} as {}", attrName, value, getOpenType(),
toStringArray(parsedArray));
return Optional.of(parsedArray);