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;
}
@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));
}
}
@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));
}
protected JSONCodec<?> unknownCodec(final UnknownTypeDefinition type) {
return NullJSONCodec.INSTANCE;
}
+
}
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
}
@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));
}
}
@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));
}
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]+");
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
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;
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);
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;
}
}
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
@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;
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;
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);
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) {
*
* <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
*
* @author Robert Varga
*/
-public interface Int16TypeDefinition extends IntegerTypeDefinition<Short, Int16TypeDefinition> {
+public interface Int16TypeDefinition extends RangeRestrictedTypeDefinition<Int16TypeDefinition, Short> {
}
*
* @author Robert Varga
*/
-public interface Int32TypeDefinition extends IntegerTypeDefinition<Integer, Int32TypeDefinition> {
+public interface Int32TypeDefinition extends RangeRestrictedTypeDefinition<Int32TypeDefinition, Integer> {
}
*
* @author Robert Varga
*/
-public interface Int64TypeDefinition extends IntegerTypeDefinition<Long, Int64TypeDefinition> {
+public interface Int64TypeDefinition extends RangeRestrictedTypeDefinition<Int64TypeDefinition, Long> {
}
*
* @author Robert Varga
*/
-public interface Int8TypeDefinition extends IntegerTypeDefinition<Byte, Int8TypeDefinition> {
+public interface Int8TypeDefinition extends RangeRestrictedTypeDefinition<Int8TypeDefinition, Byte> {
}
+++ /dev/null
-/*
- * 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> {
-
-}
*
* @author Robert Varga
*/
-public interface Uint16TypeDefinition extends UnsignedIntegerTypeDefinition<Integer, Uint16TypeDefinition> {
+public interface Uint16TypeDefinition extends RangeRestrictedTypeDefinition<Uint16TypeDefinition, Integer> {
}
*
* @author Robert Varga
*/
-public interface Uint32TypeDefinition extends UnsignedIntegerTypeDefinition<Long, Uint32TypeDefinition> {
+public interface Uint32TypeDefinition extends RangeRestrictedTypeDefinition<Uint32TypeDefinition, Long> {
}
*
* @author Robert Varga
*/
-public interface Uint64TypeDefinition extends UnsignedIntegerTypeDefinition<BigInteger, Uint64TypeDefinition> {
+public interface Uint64TypeDefinition extends RangeRestrictedTypeDefinition<Uint64TypeDefinition, BigInteger> {
}
*
* @author Robert Varga
*/
-public interface Uint8TypeDefinition extends UnsignedIntegerTypeDefinition<Short, Uint8TypeDefinition> {
+public interface Uint8TypeDefinition extends RangeRestrictedTypeDefinition<Uint8TypeDefinition, Short> {
}
+++ /dev/null
-/*
- * 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> {
-
-}
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
}
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) {
}
}
- 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);
}
private void emitDecimal64Specification(final DecimalTypeDefinition typeDefinition) {
emitFranctionDigitsNode(typeDefinition.getFractionDigits());
- typeDefinition.getRangeConstraint().ifPresent(this::emitRangeNode);
+ emitRangeRestrictedSpecification(typeDefinition);
}
private void emitFranctionDigitsNode(final Integer fractionDigits) {
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,
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-/*
- * 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);
- }
-}
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);
+ }
}
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);
+ }
+
}
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);
+ }
}
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);
+ }
}
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);
+ }
}
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);
+ }
}
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);
+ }
}
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);
+ }
}
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 {
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());
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) {
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());
}
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());
}
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();
}
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();
+ }
+
}