Eliminate (Unsigned)IntegerTypeDefinition 86/65086/8
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 3 Nov 2017 09:22:05 +0000 (10:22 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 6 Nov 2017 13:10:35 +0000 (14:10 +0100)
These two act only as intermediaries, there is no real reason to
keep them around, as all of their functions are fulfilled either
by RangeRestrictedTypeDefinition or their sub-interfaces.

Change-Id: I48698203d9073d31defba2b0c9df3d8a5859616e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
31 files changed:
yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONCodecFactory.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlCodecFactory.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/AbstractIntegerStringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/TypeDefinitionAwareCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/UnionStringCodec.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/TypeDefinitionAwareCodecTestHelper.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/codec/AbstractCodecFactory.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/package-info.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/Int16TypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/Int32TypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/Int64TypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/Int8TypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/IntegerTypeDefinition.java [deleted file]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/Uint16TypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/Uint32TypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/Uint64TypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/Uint8TypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/UnsignedIntegerTypeDefinition.java [deleted file]
yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/SchemaContextEmitter.java
yang/yang-model-immutable/src/main/java/org/opendaylight/yangtools/yang/model/immutable/package-info.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractIntegerBaseType.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractUnsignedBaseType.java [deleted file]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInt16Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInt32Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInt64Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInt8Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseUint16Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseUint32Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseUint64Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseUint8Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/TypeDefinitions.java

index 07a261fc09dabb7f3b29530ef6bab35cafe44ca2..ed9011cfc7a8079d1384d7e53af7ace8e0b4a55d 100644 (file)
@@ -40,11 +40,17 @@ import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -245,7 +251,22 @@ public final class JSONCodecFactory extends AbstractCodecFactory<JSONCodec<?>> {
     }
 
     @Override
-    protected JSONCodec<?> intCodec(final IntegerTypeDefinition<?, ?> type) {
+    protected JSONCodec<?> int8Codec(final Int8TypeDefinition type) {
+        return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected JSONCodec<?> int16Codec(final Int16TypeDefinition type) {
+        return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected JSONCodec<?> int32Codec(final Int32TypeDefinition type) {
+        return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected JSONCodec<?> int64Codec(final Int64TypeDefinition type) {
         return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
     }
 
@@ -255,7 +276,22 @@ public final class JSONCodecFactory extends AbstractCodecFactory<JSONCodec<?>> {
     }
 
     @Override
-    protected JSONCodec<?> uintCodec(final UnsignedIntegerTypeDefinition<?, ?> type) {
+    protected JSONCodec<?> uint8Codec(final Uint8TypeDefinition type) {
+        return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected JSONCodec<?> uint16Codec(final Uint16TypeDefinition type) {
+        return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected JSONCodec<?> uint32Codec(final Uint32TypeDefinition type) {
+        return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected JSONCodec<?> uint64Codec(final Uint64TypeDefinition type) {
         return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
     }
 
@@ -268,4 +304,5 @@ public final class JSONCodecFactory extends AbstractCodecFactory<JSONCodec<?>> {
     protected JSONCodec<?> unknownCodec(final UnknownTypeDefinition type) {
         return NullJSONCodec.INSTANCE;
     }
+
 }
index ee1ec83d87952946505c6ab3b933cc44a5930c66..f360324be0c2c0f6c8e9fafe681d4a778017dd78 100644 (file)
@@ -30,11 +30,17 @@ import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 @Beta
 @ThreadSafe
@@ -90,7 +96,22 @@ public final class XmlCodecFactory extends AbstractCodecFactory<XmlCodec<?>> {
     }
 
     @Override
-    protected XmlCodec<?> intCodec(final IntegerTypeDefinition type) {
+    protected XmlCodec<?> int8Codec(final Int8TypeDefinition type) {
+        return new NumberXmlCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected XmlCodec<?> int16Codec(final Int16TypeDefinition type) {
+        return new NumberXmlCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected XmlCodec<?> int32Codec(final Int32TypeDefinition type) {
+        return new NumberXmlCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected XmlCodec<?> int64Codec(final Int64TypeDefinition type) {
         return new NumberXmlCodec<>(AbstractIntegerStringCodec.from(type));
     }
 
@@ -105,7 +126,22 @@ public final class XmlCodecFactory extends AbstractCodecFactory<XmlCodec<?>> {
     }
 
     @Override
-    protected XmlCodec<?> uintCodec(final UnsignedIntegerTypeDefinition type) {
+    protected XmlCodec<?> uint8Codec(final Uint8TypeDefinition type) {
+        return new NumberXmlCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected XmlCodec<?> uint16Codec(final Uint16TypeDefinition type) {
+        return new NumberXmlCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected XmlCodec<?> uint32Codec(final Uint32TypeDefinition type) {
+        return new NumberXmlCodec<>(AbstractIntegerStringCodec.from(type));
+    }
+
+    @Override
+    protected XmlCodec<?> uint64Codec(final Uint64TypeDefinition type) {
         return new NumberXmlCodec<>(AbstractIntegerStringCodec.from(type));
     }
 
index 588dd36910ead6437bae1b32a9d6fa44a77656bb..cd77d993195ebb471740485c3856f480d196e62c 100644 (file)
@@ -12,28 +12,26 @@ import static com.google.common.base.Preconditions.checkArgument;
 import com.google.common.annotations.Beta;
 import com.google.common.base.CharMatcher;
 import com.google.common.collect.RangeSet;
+import java.math.BigInteger;
 import java.util.Optional;
 import java.util.regex.Pattern;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.RangeRestrictedTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
  * Do not use this class outside of yangtools, its presence does not fall into the API stability contract.
  */
 @Beta
-public abstract class AbstractIntegerStringCodec<N extends Number & Comparable<N>, T extends TypeDefinition<T>>
-        extends TypeDefinitionAwareCodec<N, T> {
+public abstract class AbstractIntegerStringCodec<N extends Number & Comparable<N>,
+        T extends RangeRestrictedTypeDefinition<T, N>> extends TypeDefinitionAwareCodec<N, T> {
 
     private static final Pattern INT_PATTERN = Pattern.compile("[+-]?[1-9][0-9]*$");
     private static final Pattern HEX_PATTERN = Pattern.compile("[+-]?0[xX][0-9a-fA-F]+");
@@ -57,34 +55,36 @@ public abstract class AbstractIntegerStringCodec<N extends Number & Comparable<N
         rangeConstraints = constraint.map(RangeConstraint::getAllowedRanges).orElse(null);
     }
 
-    public static AbstractIntegerStringCodec<?, ? extends IntegerTypeDefinition<?, ?>> from(
-            final IntegerTypeDefinition<?, ?> type) {
-        if (type instanceof Int8TypeDefinition) {
-            return new Int8StringCodec(Optional.of((Int8TypeDefinition) type));
-        } else if (type instanceof Int16TypeDefinition) {
-            return new Int16StringCodec(Optional.of((Int16TypeDefinition) type));
-        } else if (type instanceof Int32TypeDefinition) {
-            return new Int32StringCodec(Optional.of((Int32TypeDefinition) type));
-        } else if (type instanceof Int64TypeDefinition) {
-            return new Int64StringCodec(Optional.of((Int64TypeDefinition) type));
-        } else {
-            throw new IllegalArgumentException("Unsupported type: " + type);
-        }
+    public static AbstractIntegerStringCodec<Byte, Int8TypeDefinition> from(final Int8TypeDefinition type) {
+        return new Int8StringCodec(Optional.of(type));
     }
 
-    public static AbstractIntegerStringCodec<?, ? extends UnsignedIntegerTypeDefinition<?, ?>> from(
-            final UnsignedIntegerTypeDefinition<?, ?> type) {
-        if (type instanceof Uint8TypeDefinition) {
-            return new Uint8StringCodec(Optional.of((Uint8TypeDefinition) type));
-        } else if (type instanceof Uint16TypeDefinition) {
-            return new Uint16StringCodec(Optional.of((Uint16TypeDefinition) type));
-        } else if (type instanceof Uint32TypeDefinition) {
-            return new Uint32StringCodec(Optional.of((Uint32TypeDefinition) type));
-        } else if (type instanceof Uint64TypeDefinition) {
-            return new Uint64StringCodec(Optional.of((Uint64TypeDefinition) type));
-        } else {
-            throw new IllegalArgumentException("Unsupported type: " + type);
-        }
+    public static AbstractIntegerStringCodec<Short, Int16TypeDefinition> from(final Int16TypeDefinition type) {
+        return new Int16StringCodec(Optional.of(type));
+    }
+
+    public static AbstractIntegerStringCodec<Integer, Int32TypeDefinition> from(final Int32TypeDefinition type) {
+        return new Int32StringCodec(Optional.of(type));
+    }
+
+    public static AbstractIntegerStringCodec<Long, Int64TypeDefinition> from(final Int64TypeDefinition type) {
+        return new Int64StringCodec(Optional.of(type));
+    }
+
+    public static AbstractIntegerStringCodec<Short, Uint8TypeDefinition> from(final Uint8TypeDefinition type) {
+        return new Uint8StringCodec(Optional.of(type));
+    }
+
+    public static AbstractIntegerStringCodec<Integer, Uint16TypeDefinition> from(final Uint16TypeDefinition type) {
+        return new Uint16StringCodec(Optional.of(type));
+    }
+
+    public static AbstractIntegerStringCodec<Long, Uint32TypeDefinition> from(final Uint32TypeDefinition type) {
+        return new Uint32StringCodec(Optional.of(type));
+    }
+
+    public static AbstractIntegerStringCodec<BigInteger, Uint64TypeDefinition> from(final Uint64TypeDefinition type) {
+        return new Uint64StringCodec(Optional.of(type));
     }
 
     @Override
index 8adf6ffa227df34bb8e6aba2e2e4a203b16fe32b..8760bcd00bc26995e12a108a808dfe60635039ea 100644 (file)
@@ -17,10 +17,16 @@ import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 public abstract class TypeDefinitionAwareCodec<J, T extends TypeDefinition<T>> implements DataStringCodec<J> {
     private final Class<J> inputClass;
@@ -40,16 +46,13 @@ public abstract class TypeDefinitionAwareCodec<J, T extends TypeDefinition<T>> i
         return Optional.ofNullable(typeDefinition);
     }
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    public static TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> from(
-            final TypeDefinition typeDefinition) {
-        return (TypeDefinitionAwareCodec)fromType(typeDefinition);
+    @SuppressWarnings("unchecked")
+    public static TypeDefinitionAwareCodec<Object, ?> from(final TypeDefinition<?> typeDefinition) {
+        return (TypeDefinitionAwareCodec<Object, ?>) fromType(typeDefinition);
     }
 
-    @SuppressWarnings("unchecked")
-    public static <T extends TypeDefinition<T>> TypeDefinitionAwareCodec<?, T> fromType(final T typeDefinition) {
-        @SuppressWarnings("rawtypes")
-        final TypeDefinitionAwareCodec codec;
+    public static TypeDefinitionAwareCodec<?, ?> fromType(final TypeDefinition<?> typeDefinition) {
+        final TypeDefinitionAwareCodec<?, ?> codec;
 
         if (typeDefinition instanceof BinaryTypeDefinition) {
             codec = BinaryStringCodec.from((BinaryTypeDefinition)typeDefinition);
@@ -63,14 +66,26 @@ public abstract class TypeDefinitionAwareCodec<J, T extends TypeDefinition<T>> i
             codec = EmptyStringCodec.INSTANCE;
         } else if (typeDefinition instanceof EnumTypeDefinition) {
             codec = EnumStringCodec.from((EnumTypeDefinition)typeDefinition);
-        } else if (typeDefinition instanceof IntegerTypeDefinition) {
-            codec = AbstractIntegerStringCodec.from((IntegerTypeDefinition<?, ?>) typeDefinition);
+        } else if (typeDefinition instanceof Int8TypeDefinition) {
+            codec = AbstractIntegerStringCodec.from((Int8TypeDefinition) typeDefinition);
+        } else if (typeDefinition instanceof Int16TypeDefinition) {
+            codec = AbstractIntegerStringCodec.from((Int16TypeDefinition) typeDefinition);
+        } else if (typeDefinition instanceof Int32TypeDefinition) {
+            codec = AbstractIntegerStringCodec.from((Int32TypeDefinition) typeDefinition);
+        } else if (typeDefinition instanceof Int64TypeDefinition) {
+            codec = AbstractIntegerStringCodec.from((Int64TypeDefinition) typeDefinition);
         } else if (typeDefinition instanceof StringTypeDefinition) {
             codec = StringStringCodec.from((StringTypeDefinition)typeDefinition);
         } else if (typeDefinition instanceof UnionTypeDefinition) {
             codec = UnionStringCodec.from((UnionTypeDefinition)typeDefinition);
-        } else if (typeDefinition instanceof UnsignedIntegerTypeDefinition) {
-            codec = AbstractIntegerStringCodec.from((UnsignedIntegerTypeDefinition<?, ?>) typeDefinition);
+        } else if (typeDefinition instanceof Uint8TypeDefinition) {
+            codec = AbstractIntegerStringCodec.from((Uint8TypeDefinition) typeDefinition);
+        } else if (typeDefinition instanceof Uint16TypeDefinition) {
+            codec = AbstractIntegerStringCodec.from((Uint16TypeDefinition) typeDefinition);
+        } else if (typeDefinition instanceof Uint32TypeDefinition) {
+            codec = AbstractIntegerStringCodec.from((Uint32TypeDefinition) typeDefinition);
+        } else if (typeDefinition instanceof Uint64TypeDefinition) {
+            codec = AbstractIntegerStringCodec.from((Uint64TypeDefinition) typeDefinition);
         } else {
             codec = null;
         }
index 40d6e49a3e3277dfa01b3553db56232a80addf6f..7381992777980f08803cfa903a86897fc398bc13 100644 (file)
@@ -47,7 +47,7 @@ final class UnionStringCodec extends TypeDefinitionAwareCodec<Object, UnionTypeD
         }
 
         for (final TypeDefinition<?> type : getTypeDefinition().get().getTypes()) {
-            final TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> typeAwareCodec = from(type);
+            final TypeDefinitionAwareCodec<Object, ?> typeAwareCodec = from(type);
             if (typeAwareCodec == null) {
                 /*
                  * This is a type for which we have no codec (eg identity ref) so we'll say it's
index f2c2c671c36b2e42c0e6731f2659644f2384485d..9f73b0fc10dc9d2c3ff6273582c087bf9bf097c5 100644 (file)
@@ -29,7 +29,7 @@ public final class TypeDefinitionAwareCodecTestHelper {
 
     @SuppressWarnings("unchecked")
     public static <T> T getCodec(final TypeDefinition<?> def, final Class<T> clazz) {
-        Object codec = TypeDefinitionAwareCodec.from(def);
+        Object codec = TypeDefinitionAwareCodec.fromType(def);
         assertNotNull(codec);
         assertTrue(clazz.isAssignableFrom(codec.getClass()));
         return (T)codec;
index f7df44bbf717f41d7f3773893b86349397086818..b7f416b1795d4c63d1ec3be96d8de2f1490d3d10 100644 (file)
@@ -25,12 +25,18 @@ import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -112,13 +118,25 @@ public abstract class AbstractCodecFactory<T extends TypeAwareCodec<?, ?, ?>> {
 
     protected abstract T instanceIdentifierCodec(InstanceIdentifierTypeDefinition type);
 
-    protected abstract T intCodec(IntegerTypeDefinition<?, ?> type);
+    protected abstract T int8Codec(Int8TypeDefinition type);
+
+    protected abstract T int16Codec(Int16TypeDefinition type);
+
+    protected abstract T int32Codec(Int32TypeDefinition type);
+
+    protected abstract T int64Codec(Int64TypeDefinition type);
 
     protected abstract T decimalCodec(DecimalTypeDefinition type);
 
     protected abstract T stringCodec(StringTypeDefinition type);
 
-    protected abstract T uintCodec(UnsignedIntegerTypeDefinition<?, ?> type);
+    protected abstract T uint8Codec(Uint8TypeDefinition type);
+
+    protected abstract T uint16Codec(Uint16TypeDefinition type);
+
+    protected abstract T uint32Codec(Uint32TypeDefinition type);
+
+    protected abstract T uint64Codec(Uint64TypeDefinition type);
 
     protected abstract T unionCodec(UnionTypeDefinition type, List<T> codecs);
 
@@ -137,10 +155,22 @@ public abstract class AbstractCodecFactory<T extends TypeAwareCodec<?, ?, ?>> {
         final T ret;
         if (type instanceof StringTypeDefinition) {
             ret = stringCodec((StringTypeDefinition) type);
-        } else if (type instanceof IntegerTypeDefinition) {
-            ret = intCodec((IntegerTypeDefinition<?, ?>) type);
-        } else if (type instanceof UnsignedIntegerTypeDefinition) {
-            ret = uintCodec((UnsignedIntegerTypeDefinition<?, ?>) type);
+        } else if (type instanceof Int8TypeDefinition) {
+            ret = int8Codec((Int8TypeDefinition) type);
+        } else if (type instanceof Int16TypeDefinition) {
+            ret = int16Codec((Int16TypeDefinition) type);
+        } else if (type instanceof Int32TypeDefinition) {
+            ret = int32Codec((Int32TypeDefinition) type);
+        } else if (type instanceof Int64TypeDefinition) {
+            ret = int64Codec((Int64TypeDefinition) type);
+        } else if (type instanceof Uint8TypeDefinition) {
+            ret = uint8Codec((Uint8TypeDefinition) type);
+        } else if (type instanceof Uint16TypeDefinition) {
+            ret = uint16Codec((Uint16TypeDefinition) type);
+        } else if (type instanceof Uint32TypeDefinition) {
+            ret = uint32Codec((Uint32TypeDefinition) type);
+        } else if (type instanceof Uint64TypeDefinition) {
+            ret = uint64Codec((Uint64TypeDefinition) type);
         } else if (type instanceof BooleanTypeDefinition) {
             ret = booleanCodec((BooleanTypeDefinition) type);
         } else if (type instanceof DecimalTypeDefinition) {
index 10ee36b2bf75662907cbe051a21baf38b92f88da..fc6f6665824053f344d8b2a3e32a39a19bc1aa56 100644 (file)
  *
  * <dt>range
  *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.RangeConstraint}
- *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition#getRangeConstraint()}
- *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition#getRangeConstraint()}
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.RangeRestrictedTypeDefinition#getRangeConstraint()}
  *
  * <dt>reference
  *   <dd>{@link org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()}
  *
  *
  * <dl>
- * <dt>Integer built-in type
- *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition}
+ * <dt>Int8 built-in type
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition}
  *
- * <dt>Unsigned integer built-in type
- *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition}
+ * <dt>Int16 built-in type
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition}
  *
- * <dt>Decimal64 built-ib type
+ * <dt>Int32 built-in type
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition}
+ *
+ * <dt>Int64 built-in type
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition}
+ *
+ * <dt>Uint8 built-in type
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition}
+ *
+ * <dt>Uint16 built-in type
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition}
+ *
+ * <dt>Uint32 built-in type
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition}
+ *
+ * <dt>Uint64 built-in type
+ *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition}
+ *
+ * <dt>Decimal64 built-in type
  *   <dd>{@link org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition}
  *
  * <dt>Boolean built-in type
index ac450ffbefde0a5e35174fc9ea1906385b8ea997..17a4700a1a7010a0231cb7441199efe8718a1dd0 100644 (file)
@@ -12,6 +12,6 @@ package org.opendaylight.yangtools.yang.model.api.type;
  *
  * @author Robert Varga
  */
-public interface Int16TypeDefinition extends IntegerTypeDefinition<Short, Int16TypeDefinition> {
+public interface Int16TypeDefinition extends RangeRestrictedTypeDefinition<Int16TypeDefinition, Short> {
 
 }
index 1f22674413042c1833e30bf18f51e9bde248ac8e..442e84399e6a59a09946db0bb3d1b1ae2f7e3793 100644 (file)
@@ -12,6 +12,6 @@ package org.opendaylight.yangtools.yang.model.api.type;
  *
  * @author Robert Varga
  */
-public interface Int32TypeDefinition extends IntegerTypeDefinition<Integer, Int32TypeDefinition> {
+public interface Int32TypeDefinition extends RangeRestrictedTypeDefinition<Int32TypeDefinition, Integer> {
 
 }
index b36a18b9ff3a42868dc2e1b2ce5a7d7d128df9bc..36a36d65134c1f52220a54812dd960f73c51ab1b 100644 (file)
@@ -12,6 +12,6 @@ package org.opendaylight.yangtools.yang.model.api.type;
  *
  * @author Robert Varga
  */
-public interface Int64TypeDefinition extends IntegerTypeDefinition<Long, Int64TypeDefinition> {
+public interface Int64TypeDefinition extends RangeRestrictedTypeDefinition<Int64TypeDefinition, Long> {
 
 }
index 34f48c50cf870196010db2c5f0f3c1357d97bc21..a3d43d0806d8d79eafa7e76c9096b6979e612ee5 100644 (file)
@@ -12,6 +12,6 @@ package org.opendaylight.yangtools.yang.model.api.type;
  *
  * @author Robert Varga
  */
-public interface Int8TypeDefinition extends IntegerTypeDefinition<Byte, Int8TypeDefinition> {
+public interface Int8TypeDefinition extends RangeRestrictedTypeDefinition<Int8TypeDefinition, Byte> {
 
 }
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/IntegerTypeDefinition.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/IntegerTypeDefinition.java
deleted file mode 100644 (file)
index 19fdcaa..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.api.type;
-
-/**
- * IntegerTypeDefinition is interface which represents SIGNED Integer values defined in YANG language.<br>
- * The integer built-in types in YANG are int8, int16, int32, int64. They represent signed integers of different
- * sizes:<br>
- * <ul>
- * <li>int8 represents integer values between -128 and 127, inclusively.</li>
- * <li>int16 represents integer values between -32768 and 32767, inclusively.</li>
- * <li>int32 represents integer values between -2147483648 and 2147483647, inclusively.</li>
- * <li>int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.</li>
- * </ul>
- *
- * <p>
- * The Integer Built-In Types are defined in <a href="https://tools.ietf.org/html/rfc6020#section-9.2"> [RFC-6020]</a>
- *
- * <p>
- * Note this is an intermediate interface, concretized by sub-interfaces.
- *
- * @param <N> native representation type
- * @param <T> concrete type definition
- */
-public interface IntegerTypeDefinition<N extends Number & Comparable<N>, T extends IntegerTypeDefinition<N, T>>
-    extends RangeRestrictedTypeDefinition<T, N> {
-
-}
index 43b25df893ef291a472685400a6cde5e6d1f19cd..879003edabe41da62d58fd8d4d691bba863a29ae 100644 (file)
@@ -12,6 +12,6 @@ package org.opendaylight.yangtools.yang.model.api.type;
  *
  * @author Robert Varga
  */
-public interface Uint16TypeDefinition extends UnsignedIntegerTypeDefinition<Integer, Uint16TypeDefinition> {
+public interface Uint16TypeDefinition extends RangeRestrictedTypeDefinition<Uint16TypeDefinition, Integer> {
 
 }
index 212adb0cb739d8486d8eb3aba1c407f9a89a3569..f4a6e0dc9e4f25adb826750e580c5dd41e176b25 100644 (file)
@@ -12,6 +12,6 @@ package org.opendaylight.yangtools.yang.model.api.type;
  *
  * @author Robert Varga
  */
-public interface Uint32TypeDefinition extends UnsignedIntegerTypeDefinition<Long, Uint32TypeDefinition> {
+public interface Uint32TypeDefinition extends RangeRestrictedTypeDefinition<Uint32TypeDefinition, Long> {
 
 }
index 35dc43f92ce3298d3cb7e2afbe32d3e9c67118c3..b93ce84b04f35692651c2606ec4379b1bb48de1a 100644 (file)
@@ -14,6 +14,6 @@ import java.math.BigInteger;
  *
  * @author Robert Varga
  */
-public interface Uint64TypeDefinition extends UnsignedIntegerTypeDefinition<BigInteger, Uint64TypeDefinition> {
+public interface Uint64TypeDefinition extends RangeRestrictedTypeDefinition<Uint64TypeDefinition, BigInteger> {
 
 }
index f948df915a6a04b9bb95e55e6d3ea4fe563f4f9d..15f5beff1ae43d4128445176014fddaf52664118 100644 (file)
@@ -12,6 +12,6 @@ package org.opendaylight.yangtools.yang.model.api.type;
  *
  * @author Robert Varga
  */
-public interface Uint8TypeDefinition extends UnsignedIntegerTypeDefinition<Short, Uint8TypeDefinition> {
+public interface Uint8TypeDefinition extends RangeRestrictedTypeDefinition<Uint8TypeDefinition, Short> {
 
 }
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/UnsignedIntegerTypeDefinition.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/UnsignedIntegerTypeDefinition.java
deleted file mode 100644 (file)
index 29a3550..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.api.type;
-
-/**
- * Contains the method for getting detail data about unsigned integer.
- *
- * <p>
- * Note this is an intermediate interface, concretized by sub-interfaces.
- *
- * @param <N> native representation type
- * @param <T> concrete type definition
- */
-public interface UnsignedIntegerTypeDefinition<N extends Number & Comparable<N>,
-        T extends UnsignedIntegerTypeDefinition<N, T>> extends RangeRestrictedTypeDefinition<T, N> {
-
-}
index 3a28f320c7926025619587d65732c02dd6eb2a2f..653b91880c2fb60c4c1dd69b4468f6997f6cd449 100644 (file)
@@ -154,15 +154,14 @@ import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.ModifierKind;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.RangeRestrictedTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
 
 @Beta
@@ -1449,12 +1448,10 @@ abstract class SchemaContextEmitter {
         }
 
         private void emitTypeBodyNodes(final TypeDefinition<?> typeDef) {
-            if (typeDef instanceof UnsignedIntegerTypeDefinition) {
-                emitUnsignedIntegerSpecification((UnsignedIntegerTypeDefinition<?, ?>) typeDef);
-            } else if (typeDef instanceof IntegerTypeDefinition) {
-                emitIntegerSpefication((IntegerTypeDefinition<?, ?>) typeDef);
-            } else if (typeDef instanceof DecimalTypeDefinition) {
+            if (typeDef instanceof DecimalTypeDefinition) {
                 emitDecimal64Specification((DecimalTypeDefinition) typeDef);
+            } else if (typeDef instanceof RangeRestrictedTypeDefinition) {
+                emitRangeRestrictedSpecification((RangeRestrictedTypeDefinition<?, ?>) typeDef);
             } else if (typeDef instanceof StringTypeDefinition) {
                 emitStringRestrictions((StringTypeDefinition) typeDef);
             } else if (typeDef instanceof EnumTypeDefinition) {
@@ -1478,11 +1475,7 @@ abstract class SchemaContextEmitter {
             }
         }
 
-        private void emitIntegerSpefication(final IntegerTypeDefinition<?, ?> typeDef) {
-            typeDef.getRangeConstraint().ifPresent(this::emitRangeNode);
-        }
-
-        private void emitUnsignedIntegerSpecification(final UnsignedIntegerTypeDefinition<?, ?> typeDef) {
+        private void emitRangeRestrictedSpecification(final RangeRestrictedTypeDefinition<?, ?> typeDef) {
             typeDef.getRangeConstraint().ifPresent(this::emitRangeNode);
         }
 
@@ -1496,7 +1489,7 @@ abstract class SchemaContextEmitter {
 
         private void emitDecimal64Specification(final DecimalTypeDefinition typeDefinition) {
             emitFranctionDigitsNode(typeDefinition.getFractionDigits());
-            typeDefinition.getRangeConstraint().ifPresent(this::emitRangeNode);
+            emitRangeRestrictedSpecification(typeDefinition);
         }
 
         private void emitFranctionDigitsNode(final Integer fractionDigits) {
index df049d55226369d45ea1bd2e101ae24bf2fb8ed8..038e31ad83932045527da78d840141ce1da6c439 100644 (file)
         org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.class,
         org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair.class,
         org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition.class,
-        org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition.class,
+        org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition.class,
+        org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition.class,
+        org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition.class,
+        org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition.class,
         org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition.class,
         org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition.class,
         org.opendaylight.yangtools.yang.model.api.type.LengthConstraint.class,
         org.opendaylight.yangtools.yang.model.api.type.RangeConstraint.class,
         org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition.class,
         org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition.class,
-        org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition.class,
+        org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition.class,
+        org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition.class,
+        org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition.class,
+        org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition.class,
 })
 @Style(
     builderVisibility =  BuilderVisibility.PUBLIC,
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractIntegerBaseType.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractIntegerBaseType.java
deleted file mode 100644 (file)
index 004553a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2015 Pantheon Technologies s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.util.type;
-
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
-
-abstract class AbstractIntegerBaseType<N extends Number & Comparable<N>, T extends IntegerTypeDefinition<N, T>>
-        extends AbstractRangeRestrictedBaseType<T, N> implements IntegerTypeDefinition<N, T> {
-    AbstractIntegerBaseType(final QName qname, final N minValue, final N maxValue) {
-        super(qname, minValue, maxValue);
-    }
-
-    @Override
-    public final int hashCode() {
-        return TypeDefinitions.hashCode(this);
-    }
-
-    @Override
-    public final boolean equals(final Object obj) {
-        return TypeDefinitions.equals(this, obj);
-    }
-
-    @Override
-    public final String toString() {
-        return TypeDefinitions.toString(this);
-    }
-}
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractUnsignedBaseType.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractUnsignedBaseType.java
deleted file mode 100644 (file)
index 6ae7f5c..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2015 Pantheon Technologies s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.util.type;
-
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-
-abstract class AbstractUnsignedBaseType<N extends Number & Comparable<N>, T extends UnsignedIntegerTypeDefinition<N, T>>
-        extends AbstractRangeRestrictedBaseType<T, N> implements UnsignedIntegerTypeDefinition<N, T> {
-    AbstractUnsignedBaseType(final QName qname, final N minValue, final N maxValue) {
-        super(qname, minValue, maxValue);
-    }
-
-    @Override
-    public final int hashCode() {
-        return TypeDefinitions.hashCode(this);
-    }
-
-    @Override
-    public final boolean equals(final Object obj) {
-        return TypeDefinitions.equals(this, obj);
-    }
-
-    @Override
-    public final String toString() {
-        return TypeDefinitions.toString(this);
-    }
-}
index a09c3593bc16c72153c2f53cdd09482b756170a2..07e4b7e03eabdfeb696bb571421c5ef4caee3d2a 100644 (file)
@@ -10,10 +10,26 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
-final class BaseInt16Type extends AbstractIntegerBaseType<Short, Int16TypeDefinition> implements Int16TypeDefinition {
+final class BaseInt16Type extends AbstractRangeRestrictedBaseType<Int16TypeDefinition, Short>
+        implements Int16TypeDefinition {
     static final BaseInt16Type INSTANCE = new BaseInt16Type();
 
     private BaseInt16Type() {
         super(BaseTypes.INT16_QNAME, Short.MIN_VALUE, Short.MAX_VALUE);
     }
+
+    @Override
+    public int hashCode() {
+        return TypeDefinitions.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return TypeDefinitions.equals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return TypeDefinitions.toString(this);
+    }
 }
index abeacf8c45017931dac163aec4785554923226c5..08f3081b4e33c6ca2890ce8695802a1be8d62a45 100644 (file)
@@ -10,10 +10,27 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
-final class BaseInt32Type extends AbstractIntegerBaseType<Integer, Int32TypeDefinition> implements Int32TypeDefinition {
+final class BaseInt32Type extends AbstractRangeRestrictedBaseType<Int32TypeDefinition, Integer>
+        implements Int32TypeDefinition {
     static final BaseInt32Type INSTANCE = new BaseInt32Type();
 
     private BaseInt32Type() {
         super(BaseTypes.INT32_QNAME, Integer.MIN_VALUE, Integer.MAX_VALUE);
     }
+
+    @Override
+    public int hashCode() {
+        return TypeDefinitions.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return TypeDefinitions.equals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return TypeDefinitions.toString(this);
+    }
+
 }
index 8d69c5498b20a315e8b32c63bd79b8990c545629..9f1eb656f504fd68124ec22bc4c179af8fc225d4 100644 (file)
@@ -10,10 +10,26 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
-final class BaseInt64Type extends AbstractIntegerBaseType<Long, Int64TypeDefinition> implements Int64TypeDefinition {
+final class BaseInt64Type extends AbstractRangeRestrictedBaseType<Int64TypeDefinition, Long>
+        implements Int64TypeDefinition {
     static final BaseInt64Type INSTANCE = new BaseInt64Type();
 
     private BaseInt64Type() {
         super(BaseTypes.INT64_QNAME, Long.MIN_VALUE, Long.MAX_VALUE);
     }
+
+    @Override
+    public int hashCode() {
+        return TypeDefinitions.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return TypeDefinitions.equals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return TypeDefinitions.toString(this);
+    }
 }
index 0a871ba5b16d07e918866bcd916a343d4dff8a37..869b152c5523f3863aef808c252d5e0cd06f751f 100644 (file)
@@ -10,10 +10,26 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
-final class BaseInt8Type extends AbstractIntegerBaseType<Byte, Int8TypeDefinition> implements Int8TypeDefinition {
+final class BaseInt8Type extends AbstractRangeRestrictedBaseType<Int8TypeDefinition, Byte>
+        implements Int8TypeDefinition {
     static final BaseInt8Type INSTANCE = new BaseInt8Type();
 
     private BaseInt8Type() {
         super(BaseTypes.INT8_QNAME, Byte.MIN_VALUE, Byte.MAX_VALUE);
     }
+
+    @Override
+    public int hashCode() {
+        return TypeDefinitions.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return TypeDefinitions.equals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return TypeDefinitions.toString(this);
+    }
 }
index 475398412368e04a5d63a215453cc2b856a9351c..0514f3ccfec2d6b41731a25984f4ce23e7bd6e8d 100644 (file)
@@ -10,11 +10,26 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
-final class BaseUint16Type extends AbstractUnsignedBaseType<Integer, Uint16TypeDefinition>
+final class BaseUint16Type extends AbstractRangeRestrictedBaseType<Uint16TypeDefinition, Integer>
         implements Uint16TypeDefinition {
     static final BaseUint16Type INSTANCE = new BaseUint16Type();
 
     private BaseUint16Type() {
         super(BaseTypes.UINT16_QNAME, 0, 65535);
     }
+
+    @Override
+    public int hashCode() {
+        return TypeDefinitions.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return TypeDefinitions.equals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return TypeDefinitions.toString(this);
+    }
 }
index 36f07621f82d25259f6b3d8ae7e2f072d0561a00..4d8b52051b13f224799d31e95152b0197cdf978c 100644 (file)
@@ -10,11 +10,26 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
-final class BaseUint32Type extends AbstractUnsignedBaseType<Long, Uint32TypeDefinition>
+final class BaseUint32Type extends AbstractRangeRestrictedBaseType<Uint32TypeDefinition, Long>
         implements Uint32TypeDefinition {
     static final BaseUint32Type INSTANCE = new BaseUint32Type();
 
     private BaseUint32Type() {
         super(BaseTypes.UINT32_QNAME, 0L, 4294967295L);
     }
+
+    @Override
+    public int hashCode() {
+        return TypeDefinitions.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return TypeDefinitions.equals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return TypeDefinitions.toString(this);
+    }
 }
index f0849a7ed1d4524027ad4df0fe9fbe4a6f9f23b1..68d6ea5690399b8a2562f9f962197c332990077d 100644 (file)
@@ -11,11 +11,26 @@ import java.math.BigInteger;
 import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
-final class BaseUint64Type extends AbstractUnsignedBaseType<BigInteger, Uint64TypeDefinition>
+final class BaseUint64Type extends AbstractRangeRestrictedBaseType<Uint64TypeDefinition, BigInteger>
         implements Uint64TypeDefinition {
     static final BaseUint64Type INSTANCE = new BaseUint64Type();
 
     private BaseUint64Type() {
         super(BaseTypes.UINT64_QNAME, BigInteger.ZERO, new BigInteger("18446744073709551615"));
     }
+
+    @Override
+    public int hashCode() {
+        return TypeDefinitions.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return TypeDefinitions.equals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return TypeDefinitions.toString(this);
+    }
 }
index 14fc029acc8666c6032f1d9c28186c472582491a..31be680bbbe9af0168f913ee4d08f5226b28dba6 100644 (file)
@@ -10,10 +10,26 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
-final class BaseUint8Type extends AbstractUnsignedBaseType<Short, Uint8TypeDefinition> implements Uint8TypeDefinition {
+final class BaseUint8Type extends AbstractRangeRestrictedBaseType<Uint8TypeDefinition, Short>
+        implements Uint8TypeDefinition {
     static final BaseUint8Type INSTANCE = new BaseUint8Type();
 
     private BaseUint8Type() {
         super(BaseTypes.UINT8_QNAME, (short)0, (short)255);
     }
+
+    @Override
+    public int hashCode() {
+        return TypeDefinitions.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return TypeDefinitions.equals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return TypeDefinitions.toString(this);
+    }
 }
index a1e737466a0a149620d6068093cf35a9275f9ce7..dca40ceb2345514ed7c97ed4b47b4546a2824385 100644 (file)
@@ -19,11 +19,18 @@ import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.RangeRestrictedTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 // TODO: this should be in the API package, as it defines equality for TypeDefinitions
 final class TypeDefinitions {
@@ -101,11 +108,27 @@ final class TypeDefinitions {
             type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.requireInstance());
     }
 
-    static int hashCode(final IntegerTypeDefinition<?, ?> type) {
+    private static int hashCode(final RangeRestrictedTypeDefinition<?, ?> type) {
         return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
             type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getRangeConstraint().orElse(null));
     }
 
+    static int hashCode(final Int8TypeDefinition type) {
+        return hashCode((RangeRestrictedTypeDefinition<?, ?>) type);
+    }
+
+    static int hashCode(final Int16TypeDefinition type) {
+        return hashCode((RangeRestrictedTypeDefinition<?, ?>) type);
+    }
+
+    static int hashCode(final Int32TypeDefinition type) {
+        return hashCode((RangeRestrictedTypeDefinition<?, ?>) type);
+    }
+
+    static int hashCode(final Int64TypeDefinition type) {
+        return hashCode((RangeRestrictedTypeDefinition<?, ?>) type);
+    }
+
     static int hashCode(final LeafrefTypeDefinition type) {
         return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
             type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getPathStatement());
@@ -122,9 +145,20 @@ final class TypeDefinitions {
             type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getTypes());
     }
 
-    static int hashCode(final UnsignedIntegerTypeDefinition<?, ?> type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getRangeConstraint());
+    static int hashCode(final Uint8TypeDefinition type) {
+        return hashCode((RangeRestrictedTypeDefinition<?, ?>) type);
+    }
+
+    static int hashCode(final Uint16TypeDefinition type) {
+        return hashCode((RangeRestrictedTypeDefinition<?, ?>) type);
+    }
+
+    static int hashCode(final Uint32TypeDefinition type) {
+        return hashCode((RangeRestrictedTypeDefinition<?, ?>) type);
+    }
+
+    static int hashCode(final Uint64TypeDefinition type) {
+        return hashCode((RangeRestrictedTypeDefinition<?, ?>) type);
     }
 
     static boolean equals(final BinaryTypeDefinition type, final Object obj) {
@@ -190,12 +224,39 @@ final class TypeDefinitions {
         return other != null && type.requireInstance() == other.requireInstance();
     }
 
-    static boolean equals(final IntegerTypeDefinition type, final Object obj) {
+    static boolean equals(final Int8TypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final Int8TypeDefinition other = castIfEquals(Int8TypeDefinition.class, type, obj);
+        return other != null && type.getRangeConstraint().equals(other.getRangeConstraint());
+    }
+
+    static boolean equals(final Int16TypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final Int16TypeDefinition other = castIfEquals(Int16TypeDefinition.class, type, obj);
+        return other != null && type.getRangeConstraint().equals(other.getRangeConstraint());
+    }
+
+    static boolean equals(final Int32TypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
         }
 
-        final IntegerTypeDefinition other = castIfEquals(IntegerTypeDefinition.class, type, obj);
+        final Int32TypeDefinition other = castIfEquals(Int32TypeDefinition.class, type, obj);
+        return other != null && type.getRangeConstraint().equals(other.getRangeConstraint());
+    }
+
+    static boolean equals(final Int64TypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final Int64TypeDefinition other = castIfEquals(Int64TypeDefinition.class, type, obj);
         return other != null && type.getRangeConstraint().equals(other.getRangeConstraint());
     }
 
@@ -227,12 +288,39 @@ final class TypeDefinitions {
         return other != null && type.getTypes().equals(other.getTypes());
     }
 
-    static boolean equals(final UnsignedIntegerTypeDefinition type, final Object obj) {
+    static boolean equals(final Uint8TypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
         }
 
-        final UnsignedIntegerTypeDefinition other = castIfEquals(UnsignedIntegerTypeDefinition.class, type, obj);
+        final Uint8TypeDefinition other = castIfEquals(Uint8TypeDefinition.class, type, obj);
+        return other != null && type.getRangeConstraint().equals(other.getRangeConstraint());
+    }
+
+    static boolean equals(final Uint16TypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final Uint16TypeDefinition other = castIfEquals(Uint16TypeDefinition.class, type, obj);
+        return other != null && type.getRangeConstraint().equals(other.getRangeConstraint());
+    }
+
+    static boolean equals(final Uint32TypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final Uint32TypeDefinition other = castIfEquals(Uint32TypeDefinition.class, type, obj);
+        return other != null && type.getRangeConstraint().equals(other.getRangeConstraint());
+    }
+
+    static boolean equals(final Uint64TypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final Uint64TypeDefinition other = castIfEquals(Uint64TypeDefinition.class, type, obj);
         return other != null && type.getRangeConstraint().equals(other.getRangeConstraint());
     }
 
@@ -269,7 +357,19 @@ final class TypeDefinitions {
         return toStringHelper(type).add("requireInstance", type.requireInstance()).toString();
     }
 
-    static String toString(final IntegerTypeDefinition<?, ?> type) {
+    static String toString(final Int8TypeDefinition type) {
+        return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
+    }
+
+    static String toString(final Int16TypeDefinition type) {
+        return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
+    }
+
+    static String toString(final Int32TypeDefinition type) {
+        return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
+    }
+
+    static String toString(final Int64TypeDefinition type) {
         return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
     }
 
@@ -286,7 +386,20 @@ final class TypeDefinitions {
         return toStringHelper(type).add("types", type.getTypes()).toString();
     }
 
-    static String toString(final UnsignedIntegerTypeDefinition<?, ?> type) {
+    static String toString(final Uint8TypeDefinition type) {
+        return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
+    }
+
+    static String toString(final Uint16TypeDefinition type) {
+        return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
+    }
+
+    static String toString(final Uint32TypeDefinition type) {
         return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
     }
+
+    static String toString(final Uint64TypeDefinition type) {
+        return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
+    }
+
 }