Change mapping of uint{8,16,32,64}
[mdsal.git] / binding / mdsal-binding-generator-impl / src / main / java / org / opendaylight / mdsal / binding / yang / types / BaseYangTypes.java
index e2781c0c64aadb8f4ec7b84a0ffd3b75d25b5c91..3698e674f2213408ac1d3ee6a758a640cb50f948 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.mdsal.binding.yang.types;
 import com.google.common.collect.ImmutableMap;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigDecimal;
-import java.math.BigInteger;
 import org.opendaylight.mdsal.binding.generator.spi.TypeProvider;
 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
 import org.opendaylight.mdsal.binding.model.api.Restrictions;
@@ -19,6 +18,10 @@ import org.opendaylight.mdsal.binding.model.util.Types;
 import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 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;
@@ -69,24 +72,22 @@ public final class BaseYangTypes {
     /**
      * <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.
      */
-    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.
      */
-    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.
      */
-    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);
 
     public static final Type UNION_TYPE = new UnionType();
 
@@ -183,13 +184,13 @@ public final class BaseYangTypes {
                 case "string":
                     return Types.typeForClass(String.class, restrictions);
                 case "uint8":
-                    return Types.typeForClass(Short.class, restrictions);
+                    return Types.typeForClass(Uint8.class, restrictions);
                 case "uint16":
-                    return Types.typeForClass(Integer.class, restrictions);
+                    return Types.typeForClass(Uint16.class, restrictions);
                 case "uint32":
-                    return Types.typeForClass(Long.class, restrictions);
+                    return Types.typeForClass(Uint32.class, restrictions);
                 case "uint64":
-                    return Types.typeForClass(BigInteger.class, restrictions);
+                    return Types.typeForClass(Uint64.class, restrictions);
                 case "union" :
                     return UNION_TYPE;
                 default:
@@ -213,10 +214,6 @@ public final class BaseYangTypes {
         }
     };
 
-    private static <T extends Number & Comparable<T>> Restrictions singleRangeRestrictions(final T min, final T max) {
-        return Types.getDefaultRestrictions(min, max);
-    }
-
     // FIXME: 5.0.0: remove this class
     @Deprecated
     public static final class UnionType implements Type {