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%2FTOAttribute.java;h=d9698cc7e247bbfeae52b92e62856eb8d2aebbab;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hp=5b7385800ef417674338d76ce708c6a09e50e6bf;hpb=afa4469a5c4b0f4f0c24a10453b83287726089c7;p=controller.git diff --git a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/TOAttribute.java b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/TOAttribute.java index 5b7385800e..d9698cc7e2 100644 --- a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/TOAttribute.java +++ b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/TOAttribute.java @@ -21,6 +21,7 @@ import javax.management.openmbean.CompositeType; import javax.management.openmbean.OpenDataException; import javax.management.openmbean.OpenType; import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper; +import org.opendaylight.mdsal.binding.model.api.JavaTypeName; import org.opendaylight.mdsal.binding.model.api.Type; import org.opendaylight.mdsal.binding.model.util.ReferencedTypeImpl; import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; @@ -52,19 +53,16 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute { // Transfer Object: get the leaves final Map map = new HashMap<>(); final Map attributeNameMap = new HashMap<>(); - for (final DataSchemaNode dataSchemaNode : containerSchemaNode - .getChildNodes()) { + for (final DataSchemaNode dataSchemaNode : containerSchemaNode.getChildNodes()) { try { final String yangName = dataSchemaNode.getQName().getLocalName(); - map.put(yangName, - createInnerAttribute(dataSchemaNode, - typeProviderWrapper, packageName)); + map.put(yangName, createInnerAttribute(dataSchemaNode, typeProviderWrapper, packageName)); } catch (final IllegalArgumentException e) { throw new IllegalStateException("Unable to create TO", e); } } return new TOAttribute(containerSchemaNode, map, attributeNameMap, - containerSchemaNode.getDescription(), packageName); + containerSchemaNode.getDescription().orElse(null), packageName); } private static AttributeIfc createInnerAttribute( @@ -73,17 +71,13 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute { final Class type = isAllowedType(dataSchemaNode); if (type.equals(LeafSchemaNode.class)) { - return new JavaAttribute((LeafSchemaNode) dataSchemaNode, - typeProviderWrapper); + return new JavaAttribute((LeafSchemaNode) dataSchemaNode, typeProviderWrapper); } else if (type.equals(ListSchemaNode.class)) { - return ListAttribute.create((ListSchemaNode) dataSchemaNode, - typeProviderWrapper, packageName); + return ListAttribute.create((ListSchemaNode) dataSchemaNode, typeProviderWrapper, packageName); } else if (type.equals(LeafListSchemaNode.class)) { - return ListAttribute.create((LeafListSchemaNode) dataSchemaNode, - typeProviderWrapper); + return ListAttribute.create((LeafListSchemaNode) dataSchemaNode, typeProviderWrapper); } else if (type.equals(ContainerSchemaNode.class)) { - return TOAttribute.create((ContainerSchemaNode) dataSchemaNode, - typeProviderWrapper, packageName); + return TOAttribute.create((ContainerSchemaNode) dataSchemaNode, typeProviderWrapper, packageName); } throw new IllegalStateException("This should never happen"); @@ -92,7 +86,7 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute { private static Class isAllowedType( final DataSchemaNode dataSchemaNode) { for (final Class allowedType : ALLOWED_CHILDREN) { - if (allowedType.isAssignableFrom(dataSchemaNode.getClass()) == true) { + if (allowedType.isAssignableFrom(dataSchemaNode.getClass())) { return allowedType; } } @@ -160,7 +154,7 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute { if (this == o) { return true; } - if ((o == null) || (getClass() != o.getClass())) { + if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { @@ -190,14 +184,14 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute { @Override public int hashCode() { int result = super.hashCode(); - result = (31 - * result) + result = 31 + * result + (this.nullableDescription != null ? this.nullableDescription.hashCode() : 0); - result = (31 * result) + result = 31 * result + (this.nullableDefault != null ? this.nullableDefault.hashCode() : 0); - result = (31 - * result) + result = 31 + * result + (this.yangNameToAttributeMap != null ? this.yangNameToAttributeMap .hashCode() : 0); return result; @@ -212,7 +206,7 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute { @Override public Type getType() { // TODO: ReferencedTypeImpl from Types - return new ReferencedTypeImpl(this.packageName, getUpperCaseCammelCase()); + return new ReferencedTypeImpl(JavaTypeName.create(this.packageName, getUpperCaseCammelCase())); } @Override