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%2FJavaAttribute.java;h=3e20e4a55ad47f58e538a33594d1f5d4f0e70d32;hb=c2428fea0ac263712ab6e5dc879e19c9cf2a7c4d;hp=73c7e227be8abc03aed2bb7a5b3dc8204fe240f8;hpb=bab3649670c33b3b12a49c59fc1c5cabcbcb924e;p=controller.git diff --git a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java index 73c7e227be..3e20e4a55a 100644 --- a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java +++ b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java @@ -22,7 +22,7 @@ import javax.management.openmbean.SimpleType; public class JavaAttribute extends AbstractAttribute implements TypedAttribute { private final Type type; - private final String nullableDescription, nullableDefault; + private final String nullableDescription, nullableDefault, nullableDefaultWrappedForCode; private final TypeProviderWrapper typeProviderWrapper; private final TypeDefinition typeDefinition; @@ -33,6 +33,7 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute { this.typeDefinition = leaf.getType(); this.typeProviderWrapper = typeProviderWrapper; this.nullableDefault = leaf.getDefault(); + this.nullableDefaultWrappedForCode = leaf.getDefault() == null ? null : typeProviderWrapper.getDefault(leaf); this.nullableDescription = leaf.getDescription(); } @@ -42,10 +43,14 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute { this.type = typeProviderWrapper.getType(leaf); this.typeDefinition = leaf.getType(); this.typeProviderWrapper = typeProviderWrapper; - this.nullableDefault = null; + this.nullableDefault = nullableDefaultWrappedForCode = null; this.nullableDescription = leaf.getDescription(); } + public TypeDefinition getTypeDefinition() { + return typeDefinition; + } + /** * Returns the most base type */ @@ -56,6 +61,10 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute { return baseType; } + public String getNullableDefaultWrappedForCode() { + return nullableDefaultWrappedForCode; + } + @Override public Type getType() { return type; @@ -121,15 +130,21 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute { if (isArray()) { return getArrayType(); + } else if (isEnum(baseType)) { + return getSimpleType(baseType); } else if (isDerivedType(baseType)) { return getCompositeType(baseType, baseTypeDefinition); } - return getSimpleType(); + return getSimpleType(getType()); + } + + private boolean isEnum(Type baseType) { + return baseType.getFullyQualifiedName().equals(Enum.class.getName()); } - private OpenType getSimpleType() { - SimpleType simpleType = SimpleTypeResolver.getSimpleType(getType()); + private OpenType getSimpleType(Type type) { + SimpleType simpleType = SimpleTypeResolver.getSimpleType(type); return simpleType; }