Binding generator v2 - uses statement - uses inner type #1
[mdsal.git] / binding2 / mdsal-binding2-generator-impl / src / main / java / org / opendaylight / mdsal / binding / javav2 / generator / yang / types / BaseYangTypes.java
index 575eb5561aa63fcdf60c2ec5b0ed5405ffa3d0ef..2866b182a91850bb49a8b36c0b0e4abc8c081c57 100644 (file)
@@ -13,9 +13,10 @@ import com.google.common.collect.ImmutableMap.Builder;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.Map;
+import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
 import org.opendaylight.mdsal.binding.javav2.generator.spi.TypeProvider;
 import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifier;
-import org.opendaylight.mdsal.binding.javav2.generator.util.NonJavaCharsConverter;
+import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer;
 import org.opendaylight.mdsal.binding.javav2.generator.util.Types;
 import org.opendaylight.mdsal.binding.javav2.model.api.Restrictions;
 import org.opendaylight.mdsal.binding.javav2.model.api.Type;
@@ -154,7 +155,8 @@ public final class BaseYangTypes {
          *         returned.
          */
         @Override
-        public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode) {
+        public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode,
+                ModuleContext context) {
             if (type != null) {
                 return TYPE_MAP.get(type.getQName().getLocalName());
             }
@@ -164,38 +166,38 @@ public final class BaseYangTypes {
 
         @Override
         public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode,
-                final Restrictions restrictions) {
+                final Restrictions restrictions, ModuleContext context) {
 
-            String typeName = type.getQName().getLocalName();
+            final String typeName = type.getQName().getLocalName();
             switch (typeName) {
                 case "binary":
                     return restrictions == null ? Types.BYTE_ARRAY : Types.primitiveType("byte[]", restrictions);
                 case "decimal64":
-                    return Types.typeForClass(BigDecimal.class, restrictions);
+                    return Types.typeForClass(BigDecimal.class, restrictions, context);
                 case "enumeration":
-                    return Types.typeForClass(Enum.class, restrictions);
+                    return Types.typeForClass(Enum.class, restrictions, context);
                 case "int8":
-                    return Types.typeForClass(Byte.class, restrictions);
+                    return Types.typeForClass(Byte.class, restrictions, context);
                 case "int16":
-                    return Types.typeForClass(Short.class, restrictions);
+                    return Types.typeForClass(Short.class, restrictions, context);
                 case "int32":
-                    return Types.typeForClass(Integer.class, restrictions);
+                    return Types.typeForClass(Integer.class, restrictions, context);
                 case "int64":
-                    return Types.typeForClass(Long.class, restrictions);
+                    return Types.typeForClass(Long.class, restrictions, context);
                 case "string":
-                    return Types.typeForClass(String.class, restrictions);
+                    return Types.typeForClass(String.class, restrictions, context);
                 case "uint8":
-                    return Types.typeForClass(Short.class, restrictions);
+                    return Types.typeForClass(Short.class, restrictions, context);
                 case "uint16":
-                    return Types.typeForClass(Integer.class, restrictions);
+                    return Types.typeForClass(Integer.class, restrictions, context);
                 case "uint32":
-                    return Types.typeForClass(Long.class, restrictions);
+                    return Types.typeForClass(Long.class, restrictions, context);
                 case "uint64":
-                    return Types.typeForClass(BigInteger.class, restrictions);
+                    return Types.typeForClass(BigInteger.class, restrictions, context);
                 case "union" :
                     return UNION_TYPE;
                 default:
-                    return javaTypeForSchemaDefinitionType(type, parentNode);
+                    return javaTypeForSchemaDefinitionType(type, parentNode, context);
             }
         }
 
@@ -211,8 +213,8 @@ public final class BaseYangTypes {
 
         @Override
         public String getParamNameFromType(final TypeDefinition<?> type) {
-            return NonJavaCharsConverter.convertIdentifier(BindingMapping.getPropertyName(type.getQName()
-                    .getLocalName()), JavaIdentifier.METHOD);
+            return JavaIdentifierNormalizer.normalizeSpecificIdentifier(type.getQName().getLocalName(),
+                    JavaIdentifier.METHOD);
         }
     };