X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-jmx-generator%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyangjmxgenerator%2Fattribute%2FListAttribute.java;h=bb71f9dbc733da09c17e6be379bde458a0df7591;hb=2585706cfb4d3fff8538535212032511388bee07;hp=083b0b53e9777c2391acafb65e72011267800183;hpb=9fb64948564e252018f9b1e13e7cea2c92f991aa;p=controller.git diff --git a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/ListAttribute.java b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/ListAttribute.java index 083b0b53e9..bb71f9dbc7 100644 --- a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/ListAttribute.java +++ b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/ListAttribute.java @@ -7,24 +7,27 @@ */ package org.opendaylight.controller.config.yangjmxgenerator.attribute; -import javax.management.openmbean.ArrayType; -import javax.management.openmbean.OpenDataException; -import javax.management.openmbean.OpenType; - import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper; +import org.opendaylight.yangtools.binding.generator.util.Types; +import org.opendaylight.yangtools.sal.binding.model.api.Type; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -public class ListAttribute extends AbstractAttribute { +import javax.management.openmbean.ArrayType; +import javax.management.openmbean.OpenDataException; +import javax.management.openmbean.OpenType; +import java.util.List; + +public class ListAttribute extends AbstractAttribute implements TypedAttribute { private final String nullableDescription, nullableDefault; - private final AttributeIfc innerAttribute; + private final TypedAttribute innerAttribute; public static ListAttribute create(ListSchemaNode node, - TypeProviderWrapper typeProvider) { + TypeProviderWrapper typeProvider, String packageName) { - AttributeIfc innerAttribute = TOAttribute.create(node, typeProvider); + TOAttribute innerAttribute = TOAttribute.create(node, typeProvider, packageName); return new ListAttribute(node, innerAttribute, node.getDescription()); } @@ -32,12 +35,12 @@ public class ListAttribute extends AbstractAttribute { public static ListAttribute create(LeafListSchemaNode node, TypeProviderWrapper typeProvider) { - AttributeIfc innerAttribute = new JavaAttribute(node, typeProvider); + JavaAttribute innerAttribute = new JavaAttribute(node, typeProvider); return new ListAttribute(node, innerAttribute, node.getDescription()); } - ListAttribute(DataSchemaNode attrNode, AttributeIfc innerAttribute, + ListAttribute(DataSchemaNode attrNode, TypedAttribute innerAttribute, String description) { super(attrNode); this.nullableDescription = description; @@ -79,34 +82,49 @@ public class ListAttribute extends AbstractAttribute { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; - if (!super.equals(o)) + } + if (!super.equals(o)) { return false; + } ListAttribute that = (ListAttribute) o; if (nullableDefault != null ? !nullableDefault - .equals(that.nullableDefault) : that.nullableDefault != null) + .equals(that.nullableDefault) : that.nullableDefault != null) { return false; + } if (nullableDescription != null ? !nullableDescription .equals(that.nullableDescription) - : that.nullableDescription != null) + : that.nullableDescription != null) { return false; + } return true; } + + @Override + public Type getType() { + return Types.parameterizedTypeFor(Types.typeForClass(List.class), innerAttribute.getType()); + } + @Override public ArrayType getOpenType() { - OpenType inerOpenType = innerAttribute.getOpenType(); + OpenType innerOpenType = innerAttribute.getOpenType(); + return constructArrayType(innerOpenType); + } + + static ArrayType constructArrayType(OpenType innerOpenType){ try { - return new ArrayType<>(1, inerOpenType); + return new ArrayType<>(1, innerOpenType); } catch (OpenDataException e) { throw new RuntimeException("Unable to create " + ArrayType.class - + " with inner element of type " + inerOpenType, e); + + " with inner element of type " + innerOpenType, e); } }