Correct docs declaration
[mdsal.git] / binding2 / mdsal-binding2-generator-impl / src / main / java / org / opendaylight / mdsal / binding / javav2 / generator / yang / types / BaseYangTypes.java
index f471a32d063bc366e31a9a9bb3144c4eeea8aba8..d0b0bf091963a77f2ab25b815791a925299594cd 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.mdsal.binding.javav2.generator.yang.types;
 import com.google.common.collect.ImmutableMap;
 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;
@@ -22,6 +21,11 @@ import org.opendaylight.mdsal.binding.javav2.model.api.Restrictions;
 import org.opendaylight.mdsal.binding.javav2.model.api.Type;
 import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
 import org.opendaylight.mdsal.binding.javav2.util.BindingMapping;
+import org.opendaylight.yangtools.yang.common.Empty;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -35,84 +39,83 @@ public final class BaseYangTypes {
     private static final Map<String, Type> TYPE_MAP;
 
     /**
-     * <code>Type</code> representation of <code>binary</code> YANG type
+     * <code>Type</code> representation of <code>binary</code> YANG type.
      */
     public static final Type BINARY_TYPE = Types.primitiveType("byte[]", null);
 
     /**
-     * <code>Type</code> representation of <code>boolean</code> YANG type
+     * <code>Type</code> representation of <code>boolean</code> YANG type.
      */
     public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class);
 
     /**
-     * <code>Type</code> representation of <code>decimal64</code> YANG type
+     * <code>Type</code> representation of <code>decimal64</code> YANG type.
      */
     public static final Type DECIMAL64_TYPE = Types.typeForClass(BigDecimal.class);
 
     /**
-     * <code>Type</code> representation of <code>empty</code> YANG type
+     * <code>Type</code> representation of <code>empty</code> YANG type.
      */
-    public static final Type EMPTY_TYPE = Types.typeForClass(Boolean.class);
+    public static final Type EMPTY_TYPE = Types.typeForClass(Empty.class);
 
     /**
-     * <code>Type</code> representation of <code>enumeration</code> YANG type
+     * <code>Type</code> representation of <code>enumeration</code> YANG type.
      */
     public static final Type ENUM_TYPE = Types.typeForClass(Enum.class);
 
     /**
-     * <code>Type</code> representation of <code>instance-identifier</code> YANG type
+     * <code>Type</code> representation of <code>instance-identifier</code> YANG type.
      */
     public static final Type INSTANCE_IDENTIFIER = Types.parameterizedTypeFor(Types
             .typeForClass(InstanceIdentifier.class));
 
     /**
-     * <code>Type</code> representation of <code>int8</code> YANG type
+     * <code>Type</code> representation of <code>int8</code> YANG type.
      */
     public static final Type INT8_TYPE = Types.typeForClass(Byte.class);
 
     /**
-     * <code>Type</code> representation of <code>int16</code> YANG type
+     * <code>Type</code> representation of <code>int16</code> YANG type.
      */
     public static final Type INT16_TYPE = Types.typeForClass(Short.class);
 
     /**
-     * <code>Type</code> representation of <code>int32</code> YANG type
+     * <code>Type</code> representation of <code>int32</code> YANG type.
      */
     public static final Type INT32_TYPE = Types.typeForClass(Integer.class);
 
     /**
-     * <code>Type</code> representation of <code>int64</code> YANG type
+     * <code>Type</code> representation of <code>int64</code> YANG type.
      */
     public static final Type INT64_TYPE = Types.typeForClass(Long.class);
 
     /**
-     * <code>Type</code> representation of <code>string</code> YANG type
+     * <code>Type</code> representation of <code>string</code> YANG type.
      */
     public static final Type STRING_TYPE = Types.typeForClass(String.class);
 
     /**
-     * <code>Type</code> representation of <code>uint8</code> YANG type
+     * <code>Type</code> representation of <code>uint8</code> YANG type.
      */
-    public static final Type UINT8_TYPE = Types.typeForClass(Short.class, singleRangeRestrictions((short)0, (short)255));
+    public static final Type UINT8_TYPE = Types.typeForClass(Uint8.class);
 
     /**
-     * <code>Type</code> representation of <code>uint16</code> YANG type
+     * <code>Type</code> representation of <code>uint16</code> YANG type.
      */
-    public static final Type UINT16_TYPE = Types.typeForClass(Integer.class, singleRangeRestrictions(0, 65535));
+    public static final Type UINT16_TYPE = Types.typeForClass(Uint16.class);
 
     /**
-     * <code>Type</code> representation of <code>uint32</code> YANG type
+     * <code>Type</code> representation of <code>uint32</code> YANG type.
      */
-    public static final Type UINT32_TYPE = Types.typeForClass(Long.class, singleRangeRestrictions(0L, 4294967295L));
+    public static final Type UINT32_TYPE = Types.typeForClass(Uint32.class);
 
     /**
-     * <code>Type</code> representation of <code>uint64</code> YANG type
+     * <code>Type</code> representation of <code>uint64</code> YANG type.
      */
-    public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class,
-            singleRangeRestrictions(BigInteger.ZERO, new BigInteger("18446744073709551615")));
+    public static final Type UINT64_TYPE = Types.typeForClass(Uint64.class);
 
     /**
-     * <code>Type</code> representation of <code>union</code> YANG type
+     * <code>Type</code> representation of <code>union</code> YANG type.
      */
     public static final Type UNION_TYPE = new UnionType();
 
@@ -156,7 +159,7 @@ public final class BaseYangTypes {
          */
         @Override
         public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode,
-                ModuleContext context) {
+                final ModuleContext context) {
             if (type != null) {
                 return TYPE_MAP.get(type.getQName().getLocalName());
             }
@@ -166,34 +169,34 @@ public final class BaseYangTypes {
 
         @Override
         public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode,
-                final Restrictions restrictions, ModuleContext context) {
+                final Restrictions restrictions, final ModuleContext context) {
 
             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(Uint8.class, restrictions, context);
                 case "uint16":
-                    return Types.typeForClass(Integer.class, restrictions);
+                    return Types.typeForClass(Uint16.class, restrictions, context);
                 case "uint32":
-                    return Types.typeForClass(Long.class, restrictions);
+                    return Types.typeForClass(Uint32.class, restrictions, context);
                 case "uint64":
-                    return Types.typeForClass(BigInteger.class, restrictions);
+                    return Types.typeForClass(Uint64.class, restrictions, context);
                 case "union" :
                     return UNION_TYPE;
                 default:
@@ -218,7 +221,8 @@ public final class BaseYangTypes {
         }
     };
 
-    private static <T extends Number> Restrictions singleRangeRestrictions(final T min, final T max) {
+    @Deprecated
+    private static <T extends Number & Comparable<T>> Restrictions singleRangeRestrictions(final T min, final T max) {
         return Types.getDefaultRestrictions(min, max);
     }
 
@@ -227,10 +231,12 @@ public final class BaseYangTypes {
         public String getPackageName() {
             return BindingMapping.PACKAGE_PREFIX;
         }
+
         @Override
         public String getName() {
             return "Union";
         }
+
         @Override
         public String getFullyQualifiedName() {
             return "Union";