}
@Override
- protected JSONCodec<?> intCodec(final IntegerTypeDefinition type) {
+ protected JSONCodec<?> intCodec(final IntegerTypeDefinition<?, ?> type) {
return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
}
}
@Override
- protected JSONCodec<?> uintCodec(final UnsignedIntegerTypeDefinition type) {
+ protected JSONCodec<?> uintCodec(final UnsignedIntegerTypeDefinition<?, ?> type) {
return new NumberJSONCodec<>(AbstractIntegerStringCodec.from(type));
}
package org.opendaylight.yangtools.yang.data.impl.codec;
import static com.google.common.base.Preconditions.checkArgument;
-import static org.opendaylight.yangtools.yang.model.util.BaseTypes.INT16_QNAME;
-import static org.opendaylight.yangtools.yang.model.util.BaseTypes.INT32_QNAME;
-import static org.opendaylight.yangtools.yang.model.util.BaseTypes.INT64_QNAME;
-import static org.opendaylight.yangtools.yang.model.util.BaseTypes.INT8_QNAME;
-import static org.opendaylight.yangtools.yang.model.util.BaseTypes.UINT16_QNAME;
-import static org.opendaylight.yangtools.yang.model.util.BaseTypes.UINT32_QNAME;
-import static org.opendaylight.yangtools.yang.model.util.BaseTypes.UINT64_QNAME;
-import static org.opendaylight.yangtools.yang.model.util.BaseTypes.UINT8_QNAME;
import com.google.common.annotations.Beta;
import com.google.common.base.CharMatcher;
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.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;
/**
rangeConstraints = (RangeSet<N>) constraint.map(RangeConstraint::getAllowedRanges).orElse(null);
}
- public static AbstractIntegerStringCodec<?, IntegerTypeDefinition> from(final IntegerTypeDefinition type) {
- // FIXME: this is not necessary with yang.model.util.type
- IntegerTypeDefinition baseType = type;
- while (baseType.getBaseType() != null) {
- baseType = baseType.getBaseType();
- }
-
- final Optional<IntegerTypeDefinition> typeOptional = Optional.of(type);
-
- // FIXME: use DerivedTypes#isInt8() and friends
- if (INT8_QNAME.equals(baseType.getQName())) {
- return new Int8StringCodec(typeOptional);
- } else if (INT16_QNAME.equals(baseType.getQName())) {
- return new Int16StringCodec(typeOptional);
- } else if (INT32_QNAME.equals(baseType.getQName())) {
- return new Int32StringCodec(typeOptional);
- } else if (INT64_QNAME.equals(baseType.getQName())) {
- return new Int64StringCodec(typeOptional);
+ 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 base type: " + baseType.getQName());
+ throw new IllegalArgumentException("Unsupported type: " + type);
}
}
- public static AbstractIntegerStringCodec<?, UnsignedIntegerTypeDefinition> from(
- final UnsignedIntegerTypeDefinition type) {
- // FIXME: this is not necessary with yang.model.util.type
- UnsignedIntegerTypeDefinition baseType = type;
- while (baseType.getBaseType() != null) {
- baseType = baseType.getBaseType();
- }
-
- final Optional<UnsignedIntegerTypeDefinition> typeOptional = Optional.of(type);
-
- // FIXME: use DerivedTypes#isUint8() and friends
- if (UINT8_QNAME.equals(baseType.getQName())) {
- return new Uint8StringCodec(typeOptional);
- } else if (UINT16_QNAME.equals(baseType.getQName())) {
- return new Uint16StringCodec(typeOptional);
- } else if (UINT32_QNAME.equals(baseType.getQName())) {
- return new Uint32StringCodec(typeOptional);
- } else if (UINT64_QNAME.equals(baseType.getQName())) {
- return new Uint64StringCodec(typeOptional);
+ 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 base type: " + baseType.getQName());
+ throw new IllegalArgumentException("Unsupported type: " + type);
}
}
}
}
- protected static Optional<RangeConstraint<?>> extractRange(final IntegerTypeDefinition type) {
+ protected static Optional<RangeConstraint<?>> extractRange(final IntegerTypeDefinition<?, ?> type) {
return type == null ? Optional.empty() : type.getRangeConstraint();
}
- protected static Optional<RangeConstraint<?>> extractRange(final UnsignedIntegerTypeDefinition type) {
+ protected static Optional<RangeConstraint<?>> extractRange(final UnsignedIntegerTypeDefinition<?, ?> type) {
return type == null ? Optional.empty() : type.getRangeConstraint();
}
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.codec.Int16Codec;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
-final class Int16StringCodec extends AbstractIntegerStringCodec<Short, IntegerTypeDefinition>
+final class Int16StringCodec extends AbstractIntegerStringCodec<Short, Int16TypeDefinition>
implements Int16Codec<String> {
- Int16StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
+ Int16StringCodec(final Optional<Int16TypeDefinition> typeDef) {
super(typeDef, extractRange(typeDef.orElse(null)), Short.class);
}
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.codec.Int32Codec;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
-final class Int32StringCodec extends AbstractIntegerStringCodec<Integer, IntegerTypeDefinition>
+final class Int32StringCodec extends AbstractIntegerStringCodec<Integer, Int32TypeDefinition>
implements Int32Codec<String> {
- Int32StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
+ Int32StringCodec(final Optional<Int32TypeDefinition> typeDef) {
super(typeDef, extractRange(typeDef.orElse(null)), Integer.class);
}
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.codec.Int64Codec;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
-final class Int64StringCodec extends AbstractIntegerStringCodec<Long, IntegerTypeDefinition>
+final class Int64StringCodec extends AbstractIntegerStringCodec<Long, Int64TypeDefinition>
implements Int64Codec<String> {
- Int64StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
+ Int64StringCodec(final Optional<Int64TypeDefinition> typeDef) {
super(typeDef, extractRange(typeDef.orElse(null)), Long.class);
}
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.codec.Int8Codec;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
-final class Int8StringCodec extends AbstractIntegerStringCodec<Byte, IntegerTypeDefinition>
- implements Int8Codec<String> {
+final class Int8StringCodec extends AbstractIntegerStringCodec<Byte, Int8TypeDefinition> implements Int8Codec<String> {
- Int8StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
+ Int8StringCodec(final Optional<Int8TypeDefinition> typeDef) {
super(typeDef, extractRange(typeDef.orElse(null)), Byte.class);
}
} else if (typeDefinition instanceof EnumTypeDefinition) {
codec = EnumStringCodec.from((EnumTypeDefinition)typeDefinition);
} else if (typeDefinition instanceof IntegerTypeDefinition) {
- codec = AbstractIntegerStringCodec.from((IntegerTypeDefinition) typeDefinition);
+ codec = AbstractIntegerStringCodec.from((IntegerTypeDefinition<?, ?>) 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);
+ codec = AbstractIntegerStringCodec.from((UnsignedIntegerTypeDefinition<?, ?>) typeDefinition);
} else {
codec = null;
}
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.codec.Uint16Codec;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
-final class Uint16StringCodec extends AbstractIntegerStringCodec<Integer, UnsignedIntegerTypeDefinition> implements
+final class Uint16StringCodec extends AbstractIntegerStringCodec<Integer, Uint16TypeDefinition> implements
Uint16Codec<String> {
- Uint16StringCodec(final Optional<UnsignedIntegerTypeDefinition> typeDef) {
+ Uint16StringCodec(final Optional<Uint16TypeDefinition> typeDef) {
super(typeDef, extractRange(typeDef.orElse(null)), Integer.class);
}
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.codec.Uint32Codec;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
-final class Uint32StringCodec extends AbstractIntegerStringCodec<Long, UnsignedIntegerTypeDefinition> implements
+final class Uint32StringCodec extends AbstractIntegerStringCodec<Long, Uint32TypeDefinition> implements
Uint32Codec<String> {
- Uint32StringCodec(final Optional<UnsignedIntegerTypeDefinition> typeDef) {
+ Uint32StringCodec(final Optional<Uint32TypeDefinition> typeDef) {
super(typeDef, extractRange(typeDef.orElse(null)), Long.class);
}
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.codec.Uint64Codec;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
-final class Uint64StringCodec extends AbstractIntegerStringCodec<BigInteger, UnsignedIntegerTypeDefinition> implements
+final class Uint64StringCodec extends AbstractIntegerStringCodec<BigInteger, Uint64TypeDefinition> implements
Uint64Codec<String> {
- Uint64StringCodec(final Optional<UnsignedIntegerTypeDefinition> typeDef) {
+ Uint64StringCodec(final Optional<Uint64TypeDefinition> typeDef) {
super(typeDef, extractRange(typeDef.orElse(null)), BigInteger.class);
}
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.codec.Uint8Codec;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
-final class Uint8StringCodec extends AbstractIntegerStringCodec<Short, UnsignedIntegerTypeDefinition> implements
+final class Uint8StringCodec extends AbstractIntegerStringCodec<Short, Uint8TypeDefinition> implements
Uint8Codec<String> {
- Uint8StringCodec(final Optional<UnsignedIntegerTypeDefinition> typeDef) {
+ Uint8StringCodec(final Optional<Uint8TypeDefinition> typeDef) {
super(typeDef, extractRange(typeDef.orElse(null)), Short.class);
}
protected abstract T instanceIdentifierCodec(InstanceIdentifierTypeDefinition type);
- protected abstract T intCodec(IntegerTypeDefinition type);
+ protected abstract T intCodec(IntegerTypeDefinition<?, ?> type);
protected abstract T decimalCodec(DecimalTypeDefinition type);
protected abstract T stringCodec(StringTypeDefinition type);
- protected abstract T uintCodec(UnsignedIntegerTypeDefinition type);
+ protected abstract T uintCodec(UnsignedIntegerTypeDefinition<?, ?> type);
protected abstract T unionCodec(UnionTypeDefinition type, List<T> codecs);
if (type instanceof StringTypeDefinition) {
ret = stringCodec((StringTypeDefinition) type);
} else if (type instanceof IntegerTypeDefinition) {
- ret = intCodec((IntegerTypeDefinition) type);
+ ret = intCodec((IntegerTypeDefinition<?, ?>) type);
} else if (type instanceof UnsignedIntegerTypeDefinition) {
- ret = uintCodec((UnsignedIntegerTypeDefinition) type);
+ ret = uintCodec((UnsignedIntegerTypeDefinition<?, ?>) type);
} else if (type instanceof BooleanTypeDefinition) {
ret = booleanCodec((BooleanTypeDefinition) type);
} else if (type instanceof DecimalTypeDefinition) {
--- /dev/null
+/*
+ * Copyright (c) 2017 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.api.type;
+
+/**
+ * Type definition derived from int16 type.
+ *
+ * @author Robert Varga
+ */
+public interface Int16TypeDefinition extends IntegerTypeDefinition<Short, Int16TypeDefinition> {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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.api.type;
+
+/**
+ * Type definition derived from int32 type.
+ *
+ * @author Robert Varga
+ */
+public interface Int32TypeDefinition extends IntegerTypeDefinition<Integer, Int32TypeDefinition> {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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.api.type;
+
+/**
+ * Type definition derived from int64 type.
+ *
+ * @author Robert Varga
+ */
+public interface Int64TypeDefinition extends IntegerTypeDefinition<Long, Int64TypeDefinition> {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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.api.type;
+
+/**
+ * Type definition derived from int8 type.
+ *
+ * @author Robert Varga
+ */
+public interface Int8TypeDefinition extends IntegerTypeDefinition<Byte, Int8TypeDefinition> {
+
+}
*
* <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 extends RangeRestrictedTypeDefinition<IntegerTypeDefinition> {
+public interface IntegerTypeDefinition<N extends Number & Comparable<N>, T extends IntegerTypeDefinition<N, T>>
+ extends RangeRestrictedTypeDefinition<T> {
}
--- /dev/null
+/*
+ * Copyright (c) 2017 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.api.type;
+
+/**
+ * Type definition derived from uint16 type.
+ *
+ * @author Robert Varga
+ */
+public interface Uint16TypeDefinition extends UnsignedIntegerTypeDefinition<Integer, Uint16TypeDefinition> {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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.api.type;
+
+/**
+ * Type definition derived from uint32 type.
+ *
+ * @author Robert Varga
+ */
+public interface Uint32TypeDefinition extends UnsignedIntegerTypeDefinition<Long, Uint32TypeDefinition> {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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.api.type;
+
+import java.math.BigInteger;
+
+/**
+ * Type definition derived from uint64 type.
+ *
+ * @author Robert Varga
+ */
+public interface Uint64TypeDefinition extends UnsignedIntegerTypeDefinition<BigInteger, Uint64TypeDefinition> {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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.api.type;
+
+/**
+ * Type definition derived from uint8 type.
+ *
+ * @author Robert Varga
+ */
+public interface Uint8TypeDefinition extends UnsignedIntegerTypeDefinition<Short, Uint8TypeDefinition> {
+
+}
/**
* 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 extends RangeRestrictedTypeDefinition<UnsignedIntegerTypeDefinition> {
+public interface UnsignedIntegerTypeDefinition<N extends Number & Comparable<N>,
+ T extends UnsignedIntegerTypeDefinition<N, T>> extends RangeRestrictedTypeDefinition<T> {
}
private void emitTypeBodyNodes(final TypeDefinition<?> typeDef) {
if (typeDef instanceof UnsignedIntegerTypeDefinition) {
- emitUnsignedIntegerSpecification((UnsignedIntegerTypeDefinition) typeDef);
+ emitUnsignedIntegerSpecification((UnsignedIntegerTypeDefinition<?, ?>) typeDef);
} else if (typeDef instanceof IntegerTypeDefinition) {
- emitIntegerSpefication((IntegerTypeDefinition) typeDef);
+ emitIntegerSpefication((IntegerTypeDefinition<?, ?>) typeDef);
} else if (typeDef instanceof DecimalTypeDefinition) {
emitDecimal64Specification((DecimalTypeDefinition) typeDef);
} else if (typeDef instanceof StringTypeDefinition) {
}
}
- private void emitIntegerSpefication(final IntegerTypeDefinition typeDef) {
+ private void emitIntegerSpefication(final IntegerTypeDefinition<?, ?> typeDef) {
typeDef.getRangeConstraint().ifPresent(this::emitRangeNode);
}
- private void emitUnsignedIntegerSpecification(final UnsignedIntegerTypeDefinition typeDef) {
+ private void emitUnsignedIntegerSpecification(final UnsignedIntegerTypeDefinition<?, ?> typeDef) {
typeDef.getRangeConstraint().ifPresent(this::emitRangeNode);
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
-abstract class AbstractIntegerBaseType<C extends Number & Comparable<C>>
- extends AbstractRangeRestrictedBaseType<IntegerTypeDefinition, C> implements IntegerTypeDefinition {
- AbstractIntegerBaseType(final QName qname, final C minValue, final C maxValue) {
+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);
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-abstract class AbstractUnsignedBaseType<C extends Number & Comparable<C>>
- extends AbstractRangeRestrictedBaseType<UnsignedIntegerTypeDefinition, C>
- implements UnsignedIntegerTypeDefinition {
- AbstractUnsignedBaseType(final QName qname, final C minValue, final C maxValue) {
+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);
}
*/
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> {
+final class BaseInt16Type extends AbstractIntegerBaseType<Short, Int16TypeDefinition> implements Int16TypeDefinition {
static final BaseInt16Type INSTANCE = new BaseInt16Type();
private BaseInt16Type() {
*/
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> {
+final class BaseInt32Type extends AbstractIntegerBaseType<Integer, Int32TypeDefinition> implements Int32TypeDefinition {
static final BaseInt32Type INSTANCE = new BaseInt32Type();
private BaseInt32Type() {
*/
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> {
+final class BaseInt64Type extends AbstractIntegerBaseType<Long, Int64TypeDefinition> implements Int64TypeDefinition {
static final BaseInt64Type INSTANCE = new BaseInt64Type();
private BaseInt64Type() {
*/
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> {
+final class BaseInt8Type extends AbstractIntegerBaseType<Byte, Int8TypeDefinition> implements Int8TypeDefinition {
static final BaseInt8Type INSTANCE = new BaseInt8Type();
private BaseInt8Type() {
import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
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.UnsignedIntegerTypeDefinition;
+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;
/**
* Utility access methods for creating and accessing YANG base type definitions. YANG types come in two basic variants,
return BaseInstanceIdentifierType.INSTANCE;
}
- public static IntegerTypeDefinition int8Type() {
+ public static Int8TypeDefinition int8Type() {
return BaseInt8Type.INSTANCE;
}
+ /**
+ * Check if a particular type definition represents the built-in int8 type.
+ *
+ * @param type Type definition
+ * @return True if the definition is the built-in int8 type.
+ */
public static boolean isInt8(final TypeDefinition<?> type) {
return BaseInt8Type.INSTANCE.getPath().equals(type.getPath());
}
- public static IntegerTypeDefinition int16Type() {
+ public static Int16TypeDefinition int16Type() {
return BaseInt16Type.INSTANCE;
}
+ /**
+ * Check if a particular type definition represents the built-in int16 type.
+ *
+ * @param type Type definition
+ * @return True if the definition is the built-in int16 type.
+ */
public static boolean isInt16(final TypeDefinition<?> type) {
return BaseInt16Type.INSTANCE.getPath().equals(type.getPath());
}
- public static IntegerTypeDefinition int32Type() {
+ public static Int32TypeDefinition int32Type() {
return BaseInt32Type.INSTANCE;
}
+ /**
+ * Check if a particular type definition represents the built-in int32 type.
+ *
+ * @param type Type definition
+ * @return True if the definition is the built-in int32 type.
+ */
+
public static boolean isInt32(final TypeDefinition<?> type) {
return BaseInt32Type.INSTANCE.getPath().equals(type.getPath());
}
- public static IntegerTypeDefinition int64Type() {
+ public static Int64TypeDefinition int64Type() {
return BaseInt64Type.INSTANCE;
}
+ /**
+ * Check if a particular type definition represents the built-in int64 type.
+ *
+ * @param type Type definition
+ * @return True if the definition is the built-in int64 type.
+ */
public static boolean isInt64(final TypeDefinition<?> type) {
return BaseInt64Type.INSTANCE.getPath().equals(type.getPath());
}
return new UnionTypeBuilder(path);
}
- public static UnsignedIntegerTypeDefinition uint8Type() {
+ public static Uint8TypeDefinition uint8Type() {
return BaseUint8Type.INSTANCE;
}
return BaseUint8Type.INSTANCE.getPath().equals(type.getPath());
}
- public static UnsignedIntegerTypeDefinition uint16Type() {
+ public static Uint16TypeDefinition uint16Type() {
return BaseUint16Type.INSTANCE;
}
return BaseUint16Type.INSTANCE.getPath().equals(type.getPath());
}
- public static UnsignedIntegerTypeDefinition uint32Type() {
+ public static Uint32TypeDefinition uint32Type() {
return BaseUint32Type.INSTANCE;
}
return BaseUint32Type.INSTANCE.getPath().equals(type.getPath());
}
- public static UnsignedIntegerTypeDefinition uint64Type() {
+ public static Uint64TypeDefinition uint64Type() {
return BaseUint64Type.INSTANCE;
}
*/
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> {
+final class BaseUint16Type extends AbstractUnsignedBaseType<Integer, Uint16TypeDefinition>
+ implements Uint16TypeDefinition {
static final BaseUint16Type INSTANCE = new BaseUint16Type();
private BaseUint16Type() {
*/
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> {
+final class BaseUint32Type extends AbstractUnsignedBaseType<Long, Uint32TypeDefinition>
+ implements Uint32TypeDefinition {
static final BaseUint32Type INSTANCE = new BaseUint32Type();
private BaseUint32Type() {
package org.opendaylight.yangtools.yang.model.util.type;
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> {
+final class BaseUint64Type extends AbstractUnsignedBaseType<BigInteger, Uint64TypeDefinition>
+ implements Uint64TypeDefinition {
static final BaseUint64Type INSTANCE = new BaseUint64Type();
private BaseUint64Type() {
*/
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> {
+final class BaseUint8Type extends AbstractUnsignedBaseType<Short, Uint8TypeDefinition> implements Uint8TypeDefinition {
static final BaseUint8Type INSTANCE = new BaseUint8Type();
private BaseUint8Type() {
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
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.LengthConstraint;
import org.opendaylight.yangtools.yang.model.api.type.LengthRestrictedTypeDefinition;
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.UnsignedIntegerTypeDefinition;
+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;
/**
* Compatibility utilities for dealing with differences between the old parser's ExtendedType-driven type
return baseTypeIfNotConstrained((DecimalTypeDefinition) leafType);
} else if (leafType instanceof InstanceIdentifierTypeDefinition) {
return baseTypeIfNotConstrained((InstanceIdentifierTypeDefinition) leafType);
- } else if (leafType instanceof IntegerTypeDefinition) {
- return baseTypeIfNotConstrained((IntegerTypeDefinition) leafType);
+ } else if (leafType instanceof Int8TypeDefinition) {
+ return baseTypeIfNotConstrained((Int8TypeDefinition) leafType);
+ } else if (leafType instanceof Int16TypeDefinition) {
+ return baseTypeIfNotConstrained((Int16TypeDefinition) leafType);
+ } else if (leafType instanceof Int32TypeDefinition) {
+ return baseTypeIfNotConstrained((Int32TypeDefinition) leafType);
+ } else if (leafType instanceof Int64TypeDefinition) {
+ return baseTypeIfNotConstrained((Int64TypeDefinition) leafType);
} else if (leafType instanceof StringTypeDefinition) {
return baseTypeIfNotConstrained((StringTypeDefinition) leafType);
- } else if (leafType instanceof UnsignedIntegerTypeDefinition) {
- return baseTypeIfNotConstrained((UnsignedIntegerTypeDefinition) leafType);
+ } else if (leafType instanceof Uint8TypeDefinition) {
+ return baseTypeIfNotConstrained((Uint8TypeDefinition) leafType);
+ } else if (leafType instanceof Uint16TypeDefinition) {
+ return baseTypeIfNotConstrained((Uint16TypeDefinition) leafType);
+ } else if (leafType instanceof Uint32TypeDefinition) {
+ return baseTypeIfNotConstrained((Uint32TypeDefinition) leafType);
+ } else if (leafType instanceof Uint64TypeDefinition) {
+ return baseTypeIfNotConstrained((Uint64TypeDefinition) leafType);
} else {
// Other types cannot be constrained, return the base type
return baseType;
return type.requireInstance() == base.requireInstance() ? base : type;
}
- private static TypeDefinition<?> baseTypeIfNotConstrained(final IntegerTypeDefinition type) {
- return baseTypeIfNotConstrained(type, type.getBaseType());
- }
-
private static TypeDefinition<?> baseTypeIfNotConstrained(final StringTypeDefinition type) {
final StringTypeDefinition base = type.getBaseType();
final List<PatternConstraint> patterns = type.getPatternConstraints();
return type;
}
- private static TypeDefinition<?> baseTypeIfNotConstrained(final UnsignedIntegerTypeDefinition type) {
+ private static <T extends RangeRestrictedTypeDefinition<T>> T baseTypeIfNotConstrained(final T type) {
return baseTypeIfNotConstrained(type, type.getBaseType());
}
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.UnsignedIntegerTypeDefinition;
/**
* Support for creating {@link TypeDefinition} instances defined by leaf and leaf-list statements.
return concreteIdentityrefBuilder((IdentityrefTypeDefinition) baseType, path);
} else if (baseType instanceof InstanceIdentifierTypeDefinition) {
return concreteInstanceIdentifierBuilder((InstanceIdentifierTypeDefinition) baseType, path);
- } else if (baseType instanceof IntegerTypeDefinition) {
- return concreteIntegerBuilder((IntegerTypeDefinition) baseType, path);
+ } else if (baseType instanceof Int8TypeDefinition) {
+ return concreteInt8Builder((Int8TypeDefinition) baseType, path);
+ } else if (baseType instanceof Int16TypeDefinition) {
+ return concreteInt16Builder((Int16TypeDefinition) baseType, path);
+ } else if (baseType instanceof Int32TypeDefinition) {
+ return concreteInt32Builder((Int32TypeDefinition) baseType, path);
+ } else if (baseType instanceof Int64TypeDefinition) {
+ return concreteInt64Builder((Int64TypeDefinition) baseType, path);
} else if (baseType instanceof LeafrefTypeDefinition) {
return concreteLeafrefBuilder((LeafrefTypeDefinition) baseType, path);
} else if (baseType instanceof StringTypeDefinition) {
return concreteStringBuilder((StringTypeDefinition) baseType, path);
} else if (baseType instanceof UnionTypeDefinition) {
return concreteUnionBuilder((UnionTypeDefinition) baseType, path);
- } else if (baseType instanceof UnsignedIntegerTypeDefinition) {
- return concreteUnsignedBuilder((UnsignedIntegerTypeDefinition) baseType, path);
+ } else if (baseType instanceof Uint8TypeDefinition) {
+ return concreteUint8Builder((Uint8TypeDefinition) baseType, path);
+ } else if (baseType instanceof Uint16TypeDefinition) {
+ return concreteUint16Builder((Uint16TypeDefinition) baseType, path);
+ } else if (baseType instanceof Uint32TypeDefinition) {
+ return concreteUint32Builder((Uint32TypeDefinition) baseType, path);
+ } else if (baseType instanceof Uint64TypeDefinition) {
+ return concreteUint64Builder((Uint64TypeDefinition) baseType, path);
} else {
throw new IllegalArgumentException("Unhandled type definition class " + baseType.getClass());
}
};
}
- private static ConcreteTypeBuilder<IntegerTypeDefinition> concreteIntegerBuilder(
- final IntegerTypeDefinition baseType, final SchemaPath path) {
- return new ConcreteTypeBuilder<IntegerTypeDefinition>(baseType, path) {
+ private static ConcreteTypeBuilder<Int8TypeDefinition> concreteInt8Builder(
+ final Int8TypeDefinition baseType, final SchemaPath path) {
+ return new ConcreteTypeBuilder<Int8TypeDefinition>(baseType, path) {
@Nonnull
@Override
- public IntegerTypeDefinition buildType() {
- return new DerivedIntegerType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ public Int8TypeDefinition buildType() {
+ return new DerivedInt8Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static ConcreteTypeBuilder<Int16TypeDefinition> concreteInt16Builder(
+ final Int16TypeDefinition baseType, final SchemaPath path) {
+ return new ConcreteTypeBuilder<Int16TypeDefinition>(baseType, path) {
+ @Nonnull
+ @Override
+ public Int16TypeDefinition buildType() {
+ return new DerivedInt16Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static ConcreteTypeBuilder<Int32TypeDefinition> concreteInt32Builder(
+ final Int32TypeDefinition baseType, final SchemaPath path) {
+ return new ConcreteTypeBuilder<Int32TypeDefinition>(baseType, path) {
+ @Nonnull
+ @Override
+ public Int32TypeDefinition buildType() {
+ return new DerivedInt32Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static ConcreteTypeBuilder<Int64TypeDefinition> concreteInt64Builder(
+ final Int64TypeDefinition baseType, final SchemaPath path) {
+ return new ConcreteTypeBuilder<Int64TypeDefinition>(baseType, path) {
+ @Nonnull
+ @Override
+ public Int64TypeDefinition buildType() {
+ return new DerivedInt64Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
}
};
};
}
- private static ConcreteTypeBuilder<UnsignedIntegerTypeDefinition> concreteUnsignedBuilder(
- final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
- return new ConcreteTypeBuilder<UnsignedIntegerTypeDefinition>(baseType, path) {
+ private static ConcreteTypeBuilder<Uint8TypeDefinition> concreteUint8Builder(
+ final Uint8TypeDefinition baseType, final SchemaPath path) {
+ return new ConcreteTypeBuilder<Uint8TypeDefinition>(baseType, path) {
+ @Nonnull
+ @Override
+ public Uint8TypeDefinition buildType() {
+ return new DerivedUint8Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static ConcreteTypeBuilder<Uint16TypeDefinition> concreteUint16Builder(
+ final Uint16TypeDefinition baseType, final SchemaPath path) {
+ return new ConcreteTypeBuilder<Uint16TypeDefinition>(baseType, path) {
+ @Nonnull
+ @Override
+ public Uint16TypeDefinition buildType() {
+ return new DerivedUint16Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static ConcreteTypeBuilder<Uint32TypeDefinition> concreteUint32Builder(
+ final Uint32TypeDefinition baseType, final SchemaPath path) {
+ return new ConcreteTypeBuilder<Uint32TypeDefinition>(baseType, path) {
+ @Nonnull
+ @Override
+ public Uint32TypeDefinition buildType() {
+ return new DerivedUint32Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static ConcreteTypeBuilder<Uint64TypeDefinition> concreteUint64Builder(
+ final Uint64TypeDefinition baseType, final SchemaPath path) {
+ return new ConcreteTypeBuilder<Uint64TypeDefinition>(baseType, path) {
@Nonnull
@Override
- public UnsignedIntegerTypeDefinition buildType() {
- return new DerivedUnsignedType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ public Uint64TypeDefinition buildType() {
+ return new DerivedUint64Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
}
};
/*
- * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
+ * Copyright (c) 2017 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,
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
-final class DerivedIntegerType extends AbstractRangeRestrictedDerivedType<IntegerTypeDefinition>
- implements IntegerTypeDefinition {
- DerivedIntegerType(final IntegerTypeDefinition baseType, final SchemaPath path, final Object defaultValue,
+final class DerivedInt16Type extends AbstractRangeRestrictedDerivedType<Int16TypeDefinition>
+ implements Int16TypeDefinition {
+ DerivedInt16Type(final Int16TypeDefinition baseType, final SchemaPath path, final Object defaultValue,
final String description, final String reference, final Status status, final String units,
final Collection<UnknownSchemaNode> unknownSchemaNodes) {
super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
+
+final class DerivedInt32Type extends AbstractRangeRestrictedDerivedType<Int32TypeDefinition>
+ implements Int32TypeDefinition {
+ DerivedInt32Type(final Int32TypeDefinition baseType, final SchemaPath path, final Object defaultValue,
+ final String description, final String reference, final Status status, final String units,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+ super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
+ }
+
+ @Override
+ public int hashCode() {
+ return TypeDefinitions.hashCode(this);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return TypeDefinitions.equals(this, obj);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
+
+final class DerivedInt64Type extends AbstractRangeRestrictedDerivedType<Int64TypeDefinition>
+ implements Int64TypeDefinition {
+ DerivedInt64Type(final Int64TypeDefinition baseType, final SchemaPath path, final Object defaultValue,
+ final String description, final String reference, final Status status, final String units,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+ super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
+ }
+
+ @Override
+ public int hashCode() {
+ return TypeDefinitions.hashCode(this);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return TypeDefinitions.equals(this, obj);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
+
+final class DerivedInt8Type extends AbstractRangeRestrictedDerivedType<Int8TypeDefinition>
+ implements Int8TypeDefinition {
+ DerivedInt8Type(final Int8TypeDefinition baseType, final SchemaPath path, final Object defaultValue,
+ final String description, final String reference, final Status status, final String units,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+ super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
+ }
+
+ @Override
+ public int hashCode() {
+ return TypeDefinitions.hashCode(this);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return TypeDefinitions.equals(this, obj);
+ }
+}
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
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.UnsignedIntegerTypeDefinition;
/**
* YANG defines 'derived type' as a type created through a 'typedef' statement. These types are exposed in the
return derivedIdentityrefBuilder((IdentityrefTypeDefinition) baseType, path);
} else if (baseType instanceof InstanceIdentifierTypeDefinition) {
return derivedInstanceIdentifierBuilder((InstanceIdentifierTypeDefinition) baseType, path);
- } else if (baseType instanceof IntegerTypeDefinition) {
- return derivedIntegerBuilder((IntegerTypeDefinition) baseType, path);
+ } else if (baseType instanceof Int8TypeDefinition) {
+ return derivedInt8Builder((Int8TypeDefinition) baseType, path);
+ } else if (baseType instanceof Int16TypeDefinition) {
+ return derivedInt16Builder((Int16TypeDefinition) baseType, path);
+ } else if (baseType instanceof Int32TypeDefinition) {
+ return derivedInt32Builder((Int32TypeDefinition) baseType, path);
+ } else if (baseType instanceof Int64TypeDefinition) {
+ return derivedInt64Builder((Int64TypeDefinition) baseType, path);
} else if (baseType instanceof LeafrefTypeDefinition) {
return derivedLeafrefBuilder((LeafrefTypeDefinition) baseType, path);
} else if (baseType instanceof StringTypeDefinition) {
return derivedStringBuilder((StringTypeDefinition) baseType, path);
} else if (baseType instanceof UnionTypeDefinition) {
return derivedUnionBuilder((UnionTypeDefinition) baseType, path);
- } else if (baseType instanceof UnsignedIntegerTypeDefinition) {
- return derivedUnsignedBuilder((UnsignedIntegerTypeDefinition) baseType, path);
+ } else if (baseType instanceof Uint8TypeDefinition) {
+ return derivedUint8Builder((Uint8TypeDefinition) baseType, path);
+ } else if (baseType instanceof Uint16TypeDefinition) {
+ return derivedUint16Builder((Uint16TypeDefinition) baseType, path);
+ } else if (baseType instanceof Uint32TypeDefinition) {
+ return derivedUint32Builder((Uint32TypeDefinition) baseType, path);
+ } else if (baseType instanceof Uint64TypeDefinition) {
+ return derivedUint64Builder((Uint64TypeDefinition) baseType, path);
} else {
throw new IllegalArgumentException("Unhandled type definition class " + baseType.getClass());
}
}
/**
- * Check if a particular type is corresponds to int8. Unlike {@link BaseTypes#isInt8(TypeDefinition)}, this
- * method performs recursive lookup to find the base type.
+ * Check if a particular type is itself, or is derived from, int8.
*
* @param type The type to check
* @return If the type belongs to the int8 type family.
* @throws NullPointerException if type is null
+ *
+ * @deprecated Use @{code type instanceof Int8TypeDefinition} instead.
*/
+ @Deprecated
public static boolean isInt8(@Nonnull final TypeDefinition<?> type) {
- return BaseTypes.isInt8(BaseTypes.baseTypeOf(type));
+ return requireNonNull(type) instanceof Int8TypeDefinition;
}
/**
- * Check if a particular type is corresponds to int16. Unlike {@link BaseTypes#isInt16(TypeDefinition)}, this
- * method performs recursive lookup to find the base type.
+ * Check if a particular type is itself, or is derived from, int16.
*
* @param type The type to check
* @return If the type belongs to the int16 type family.
* @throws NullPointerException if type is null
+ *
+ * @deprecated Use @{code type instanceof Int16TypeDefinition} instead.
*/
+ @Deprecated
public static boolean isInt16(@Nonnull final TypeDefinition<?> type) {
- return BaseTypes.isInt16(BaseTypes.baseTypeOf(type));
+ return requireNonNull(type) instanceof Int16TypeDefinition;
}
/**
- * Check if a particular type is corresponds to int32. Unlike {@link BaseTypes#isInt32(TypeDefinition)}, this
- * method performs recursive lookup to find the base type.
+ * Check if a particular type is itself, or is derived from, int32.
*
* @param type The type to check
* @return If the type belongs to the int32 type family.
* @throws NullPointerException if type is null
+ *
+ * @deprecated Use @{code type instanceof Int32TypeDefinition} instead.
*/
+ @Deprecated
public static boolean isInt32(@Nonnull final TypeDefinition<?> type) {
- return BaseTypes.isInt32(BaseTypes.baseTypeOf(type));
+ return requireNonNull(type) instanceof Int32TypeDefinition;
}
/**
- * Check if a particular type is corresponds to int64. Unlike {@link BaseTypes#isInt64(TypeDefinition)}, this
- * method performs recursive lookup to find the base type.
+ * Check if a particular type is itself, or is derived from, int64.
*
* @param type The type to check
* @return If the type belongs to the int64 type family.
* @throws NullPointerException if type is null
+ *
+ * @deprecated Use @{code type instanceof Int64TypeDefinition} instead.
*/
+ @Deprecated
public static boolean isInt64(@Nonnull final TypeDefinition<?> type) {
- return BaseTypes.isInt64(BaseTypes.baseTypeOf(type));
+ return requireNonNull(type) instanceof Int64TypeDefinition;
}
/**
- * Check if a particular type is corresponds to uint8. Unlike {@link BaseTypes#isUint8(TypeDefinition)}, this
- * method performs recursive lookup to find the base type.
+ * Check if a particular type is itself, or is derived from, uint8.
*
* @param type The type to check
* @return If the type belongs to the uint8 type family.
* @throws NullPointerException if type is null
+ *
+ * @deprecated Use @{code type instanceof Uint8TypeDefinition} instead.
*/
+ @Deprecated
public static boolean isUint8(@Nonnull final TypeDefinition<?> type) {
- return BaseTypes.isUint8(BaseTypes.baseTypeOf(type));
+ return requireNonNull(type) instanceof Uint8TypeDefinition;
}
/**
- * Check if a particular type is corresponds to uint16. Unlike {@link BaseTypes#isUint16(TypeDefinition)}, this
- * method performs recursive lookup to find the base type.
+ * Check if a particular type is itself, or is derived from, uint16.
*
* @param type The type to check
* @return If the type belongs to the uint16 type family.
* @throws NullPointerException if type is null
+ *
+ * @deprecated Use @{code type instanceof Uint16TypeDefinition} instead.
*/
+ @Deprecated
public static boolean isUint16(@Nonnull final TypeDefinition<?> type) {
- return BaseTypes.isUint16(BaseTypes.baseTypeOf(type));
+ return requireNonNull(type) instanceof Uint16TypeDefinition;
}
/**
- * Check if a particular type is corresponds to uint32. Unlike {@link BaseTypes#isUint32(TypeDefinition)}, this
- * method performs recursive lookup to find the base type.
+ * Check if a particular type is itself, or is derived from, uint32.
*
* @param type The type to check
* @return If the type belongs to the uint32 type family.
* @throws NullPointerException if type is null
+ *
+ * @deprecated Use @{code type instanceof Uint32TypeDefinition} instead.
*/
+ @Deprecated
public static boolean isUint32(@Nonnull final TypeDefinition<?> type) {
- return BaseTypes.isUint32(BaseTypes.baseTypeOf(type));
+ return requireNonNull(type) instanceof Uint32TypeDefinition;
}
/**
- * Check if a particular type is corresponds to uint64. Unlike {@link BaseTypes#isUint64(TypeDefinition)}, this
- * method performs recursive lookup to find the base type.
+ * Check if a particular type is itself, or is derived from, uint64.
*
* @param type The type to check
* @return If the type belongs to the uint64 type family.
* @throws NullPointerException if type is null
+ *
+ * @deprecated Use @{code type instanceof Uint64TypeDefinition} instead.
*/
+ @Deprecated
public static boolean isUint64(@Nonnull final TypeDefinition<?> type) {
- return BaseTypes.isUint64(BaseTypes.baseTypeOf(type));
+ return requireNonNull(type) instanceof Uint64TypeDefinition;
}
private static DerivedTypeBuilder<BinaryTypeDefinition> derivedBinaryBuilder(
};
}
- private static DerivedTypeBuilder<IntegerTypeDefinition> derivedIntegerBuilder(final IntegerTypeDefinition baseType,
+ private static DerivedTypeBuilder<Int8TypeDefinition> derivedInt8Builder(final Int8TypeDefinition baseType,
+ final SchemaPath path) {
+ return new DerivedTypeBuilder<Int8TypeDefinition>(baseType, path) {
+ @Override
+ public Int8TypeDefinition build() {
+ return new DerivedInt8Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static DerivedTypeBuilder<Int16TypeDefinition> derivedInt16Builder(final Int16TypeDefinition baseType,
+ final SchemaPath path) {
+ return new DerivedTypeBuilder<Int16TypeDefinition>(baseType, path) {
+ @Override
+ public Int16TypeDefinition build() {
+ return new DerivedInt16Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static DerivedTypeBuilder<Int32TypeDefinition> derivedInt32Builder(final Int32TypeDefinition baseType,
+ final SchemaPath path) {
+ return new DerivedTypeBuilder<Int32TypeDefinition>(baseType, path) {
+ @Override
+ public Int32TypeDefinition build() {
+ return new DerivedInt32Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static DerivedTypeBuilder<Int64TypeDefinition> derivedInt64Builder(final Int64TypeDefinition baseType,
final SchemaPath path) {
- return new DerivedTypeBuilder<IntegerTypeDefinition>(baseType, path) {
+ return new DerivedTypeBuilder<Int64TypeDefinition>(baseType, path) {
@Override
- public IntegerTypeDefinition build() {
- return new DerivedIntegerType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ public Int64TypeDefinition build() {
+ return new DerivedInt64Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
}
};
};
}
- private static DerivedTypeBuilder<UnsignedIntegerTypeDefinition> derivedUnsignedBuilder(
- final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
- return new DerivedTypeBuilder<UnsignedIntegerTypeDefinition>(baseType, path) {
+ private static DerivedTypeBuilder<Uint8TypeDefinition> derivedUint8Builder(
+ final Uint8TypeDefinition baseType, final SchemaPath path) {
+ return new DerivedTypeBuilder<Uint8TypeDefinition>(baseType, path) {
+ @Override
+ public Uint8TypeDefinition build() {
+ return new DerivedUint8Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static DerivedTypeBuilder<Uint16TypeDefinition> derivedUint16Builder(
+ final Uint16TypeDefinition baseType, final SchemaPath path) {
+ return new DerivedTypeBuilder<Uint16TypeDefinition>(baseType, path) {
+ @Override
+ public Uint16TypeDefinition build() {
+ return new DerivedUint16Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static DerivedTypeBuilder<Uint32TypeDefinition> derivedUint32Builder(
+ final Uint32TypeDefinition baseType, final SchemaPath path) {
+ return new DerivedTypeBuilder<Uint32TypeDefinition>(baseType, path) {
+ @Override
+ public Uint32TypeDefinition build() {
+ return new DerivedUint32Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
+ }
+ };
+ }
+
+ private static DerivedTypeBuilder<Uint64TypeDefinition> derivedUint64Builder(
+ final Uint64TypeDefinition baseType, final SchemaPath path) {
+ return new DerivedTypeBuilder<Uint64TypeDefinition>(baseType, path) {
@Override
- public UnsignedIntegerTypeDefinition build() {
- return new DerivedUnsignedType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+ public Uint64TypeDefinition build() {
+ return new DerivedUint64Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
}
};
/*
- * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
+ * Copyright (c) 2017 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,
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
-final class DerivedUnsignedType extends AbstractRangeRestrictedDerivedType<UnsignedIntegerTypeDefinition>
- implements UnsignedIntegerTypeDefinition {
+final class DerivedUint16Type extends AbstractRangeRestrictedDerivedType<Uint16TypeDefinition>
+ implements Uint16TypeDefinition {
- DerivedUnsignedType(final UnsignedIntegerTypeDefinition baseType, final SchemaPath path,
+ DerivedUint16Type(final Uint16TypeDefinition baseType, final SchemaPath path,
final Object defaultValue, final String description, final String reference, final Status status,
final String units, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
+
+final class DerivedUint32Type extends AbstractRangeRestrictedDerivedType<Uint32TypeDefinition>
+ implements Uint32TypeDefinition {
+
+ DerivedUint32Type(final Uint32TypeDefinition baseType, final SchemaPath path,
+ final Object defaultValue, final String description, final String reference, final Status status,
+ final String units, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+ super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
+ }
+
+ @Override
+ public int hashCode() {
+ return TypeDefinitions.hashCode(this);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return TypeDefinitions.equals(this, obj);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
+
+final class DerivedUint64Type extends AbstractRangeRestrictedDerivedType<Uint64TypeDefinition>
+ implements Uint64TypeDefinition {
+
+ DerivedUint64Type(final Uint64TypeDefinition baseType, final SchemaPath path,
+ final Object defaultValue, final String description, final String reference, final Status status,
+ final String units, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+ super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
+ }
+
+ @Override
+ public int hashCode() {
+ return TypeDefinitions.hashCode(this);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return TypeDefinitions.equals(this, obj);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
+
+final class DerivedUint8Type extends AbstractRangeRestrictedDerivedType<Uint8TypeDefinition>
+ implements Uint8TypeDefinition {
+
+ DerivedUint8Type(final Uint8TypeDefinition baseType, final SchemaPath path,
+ final Object defaultValue, final String description, final String reference, final Status status,
+ final String units, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+ super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
+ }
+
+ @Override
+ public int hashCode() {
+ return TypeDefinitions.hashCode(this);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return TypeDefinitions.equals(this, obj);
+ }
+}
/*
- * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
+ * Copyright (c) 2017 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,
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-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.RangeConstraint;
-final class RestrictedIntegerType extends AbstractRangeRestrictedType<IntegerTypeDefinition>
- implements IntegerTypeDefinition {
- RestrictedIntegerType(final IntegerTypeDefinition baseType, final SchemaPath path,
+final class RestrictedInt16Type extends AbstractRangeRestrictedType<Int16TypeDefinition>
+ implements Int16TypeDefinition {
+ RestrictedInt16Type(final Int16TypeDefinition baseType, final SchemaPath path,
final Collection<UnknownSchemaNode> unknownSchemaNodes, final @Nullable RangeConstraint<?> rangeConstraint) {
super(baseType, path, unknownSchemaNodes, rangeConstraint);
}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+
+final class RestrictedInt32Type extends AbstractRangeRestrictedType<Int32TypeDefinition>
+ implements Int32TypeDefinition {
+ RestrictedInt32Type(final Int32TypeDefinition baseType, final SchemaPath path,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes, final @Nullable RangeConstraint<?> rangeConstraint) {
+ super(baseType, path, unknownSchemaNodes, rangeConstraint);
+ }
+
+ @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);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+
+final class RestrictedInt64Type extends AbstractRangeRestrictedType<Int64TypeDefinition>
+ implements Int64TypeDefinition {
+ RestrictedInt64Type(final Int64TypeDefinition baseType, final SchemaPath path,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes, final @Nullable RangeConstraint<?> rangeConstraint) {
+ super(baseType, path, unknownSchemaNodes, rangeConstraint);
+ }
+
+ @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);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+
+final class RestrictedInt8Type extends AbstractRangeRestrictedType<Int8TypeDefinition> implements Int8TypeDefinition {
+ RestrictedInt8Type(final Int8TypeDefinition baseType, final SchemaPath path,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes, final @Nullable RangeConstraint<?> rangeConstraint) {
+ super(baseType, path, unknownSchemaNodes, rangeConstraint);
+ }
+
+ @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.LengthConstraint;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
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;
/**
* Restricted types are a refinement of the restrictions applied to a particular type. YANG defines restrictions only
};
}
- public static RangeRestrictedTypeBuilder<IntegerTypeDefinition> newIntegerBuilder(
- final IntegerTypeDefinition baseType, final SchemaPath path) {
- return new RangeRestrictedTypeBuilderWithBase<IntegerTypeDefinition>(baseType, path) {
+ public static RangeRestrictedTypeBuilder<Int8TypeDefinition> newInt8Builder(
+ final Int8TypeDefinition baseType, final SchemaPath path) {
+ return new RangeRestrictedTypeBuilderWithBase<Int8TypeDefinition>(baseType, path) {
@Override
- IntegerTypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
- return new RestrictedIntegerType(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
+ Int8TypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
+ return new RestrictedInt8Type(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
+ }
+ };
+ }
+
+ public static RangeRestrictedTypeBuilder<Int16TypeDefinition> newInt16Builder(
+ final Int16TypeDefinition baseType, final SchemaPath path) {
+ return new RangeRestrictedTypeBuilderWithBase<Int16TypeDefinition>(baseType, path) {
+ @Override
+ Int16TypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
+ return new RestrictedInt16Type(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
+ }
+ };
+ }
+
+ public static RangeRestrictedTypeBuilder<Int32TypeDefinition> newInt32Builder(
+ final Int32TypeDefinition baseType, final SchemaPath path) {
+ return new RangeRestrictedTypeBuilderWithBase<Int32TypeDefinition>(baseType, path) {
+ @Override
+ Int32TypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
+ return new RestrictedInt32Type(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
+ }
+ };
+ }
+
+ public static RangeRestrictedTypeBuilder<Int64TypeDefinition> newInt64Builder(
+ final Int64TypeDefinition baseType, final SchemaPath path) {
+ return new RangeRestrictedTypeBuilderWithBase<Int64TypeDefinition>(baseType, path) {
+ @Override
+ Int64TypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
+ return new RestrictedInt64Type(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
}
};
}
};
}
- public static RangeRestrictedTypeBuilder<UnsignedIntegerTypeDefinition> newUnsignedBuilder(
- final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
- return new RangeRestrictedTypeBuilderWithBase<UnsignedIntegerTypeDefinition>(baseType, path) {
+ public static RangeRestrictedTypeBuilder<Uint8TypeDefinition> newUint8Builder(
+ final Uint8TypeDefinition baseType, final SchemaPath path) {
+ return new RangeRestrictedTypeBuilderWithBase<Uint8TypeDefinition>(baseType, path) {
+ @Override
+ Uint8TypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
+ return new RestrictedUint8Type(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
+ }
+ };
+ }
+
+ public static RangeRestrictedTypeBuilder<Uint16TypeDefinition> newUint16Builder(
+ final Uint16TypeDefinition baseType, final SchemaPath path) {
+ return new RangeRestrictedTypeBuilderWithBase<Uint16TypeDefinition>(baseType, path) {
+ @Override
+ Uint16TypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
+ return new RestrictedUint16Type(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
+ }
+ };
+ }
+
+ public static RangeRestrictedTypeBuilder<Uint32TypeDefinition> newUint32Builder(
+ final Uint32TypeDefinition baseType, final SchemaPath path) {
+ return new RangeRestrictedTypeBuilderWithBase<Uint32TypeDefinition>(baseType, path) {
+ @Override
+ Uint32TypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
+ return new RestrictedUint32Type(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
+ }
+ };
+ }
+
+ public static RangeRestrictedTypeBuilder<Uint64TypeDefinition> newUint64Builder(
+ final Uint64TypeDefinition baseType, final SchemaPath path) {
+ return new RangeRestrictedTypeBuilderWithBase<Uint64TypeDefinition>(baseType, path) {
@Override
- UnsignedIntegerTypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
- return new RestrictedUnsignedType(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
+ Uint64TypeDefinition buildType(final RangeConstraint<?> rangeConstraint) {
+ return new RestrictedUint64Type(getBaseType(), getPath(), getUnknownSchemaNodes(), rangeConstraint);
}
};
}
/*
- * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
+ * Copyright (c) 2017 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,
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
-final class RestrictedUnsignedType extends AbstractRangeRestrictedType<UnsignedIntegerTypeDefinition>
- implements UnsignedIntegerTypeDefinition {
+final class RestrictedUint16Type extends AbstractRangeRestrictedType<Uint16TypeDefinition>
+ implements Uint16TypeDefinition {
- RestrictedUnsignedType(final UnsignedIntegerTypeDefinition baseType, final SchemaPath path,
+ RestrictedUint16Type(final Uint16TypeDefinition baseType, final SchemaPath path,
final Collection<UnknownSchemaNode> unknownSchemaNodes, final @Nullable RangeConstraint<?> rangeConstraint) {
super(baseType, path, unknownSchemaNodes, rangeConstraint);
}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
+
+final class RestrictedUint32Type extends AbstractRangeRestrictedType<Uint32TypeDefinition>
+ implements Uint32TypeDefinition {
+
+ RestrictedUint32Type(final Uint32TypeDefinition baseType, final SchemaPath path,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes, final @Nullable RangeConstraint<?> rangeConstraint) {
+ super(baseType, path, unknownSchemaNodes, rangeConstraint);
+ }
+
+ @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);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
+
+final class RestrictedUint64Type extends AbstractRangeRestrictedType<Uint64TypeDefinition>
+ implements Uint64TypeDefinition {
+
+ RestrictedUint64Type(final Uint64TypeDefinition baseType, final SchemaPath path,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes, final @Nullable RangeConstraint<?> rangeConstraint) {
+ super(baseType, path, unknownSchemaNodes, rangeConstraint);
+ }
+
+ @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);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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 java.util.Collection;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
+
+final class RestrictedUint8Type extends AbstractRangeRestrictedType<Uint8TypeDefinition>
+ implements Uint8TypeDefinition {
+
+ RestrictedUint8Type(final Uint8TypeDefinition baseType, final SchemaPath path,
+ final Collection<UnknownSchemaNode> unknownSchemaNodes, final @Nullable RangeConstraint<?> rangeConstraint) {
+ super(baseType, path, unknownSchemaNodes, rangeConstraint);
+ }
+
+ @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);
+ }
+}
type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.requireInstance());
}
- static int hashCode(final IntegerTypeDefinition type) {
+ static int hashCode(final IntegerTypeDefinition<?, ?> type) {
return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getRangeConstraint().orElse(null));
}
type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getTypes());
}
- static int hashCode(final UnsignedIntegerTypeDefinition type) {
+ static int hashCode(final UnsignedIntegerTypeDefinition<?, ?> type) {
return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
type.getDefaultValue(), type.getRangeConstraint());
}
return toStringHelper(type).add("requireInstance", type.requireInstance()).toString();
}
- static String toString(final IntegerTypeDefinition type) {
+ static String toString(final IntegerTypeDefinition<?, ?> 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 UnsignedIntegerTypeDefinition<?, ?> type) {
return toStringHelper(type).add("range", type.getRangeConstraint().orElse(null)).toString();
}
}
import java.util.Optional;
import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
public class Int8Test {
@Test
public void testInt8() {
- IntegerTypeDefinition int8 = BaseTypes.int8Type();
- IntegerTypeDefinition int8Second = BaseTypes.int8Type();
+ Int8TypeDefinition int8 = BaseTypes.int8Type();
+ Int8TypeDefinition int8Second = BaseTypes.int8Type();
assertSame("The method 'getInstance()' has to return the same instance", int8, int8Second);
assertNull("The method 'getBaseType()' is returning incorrect value", int8.getBaseType());
assertEquals("The method 'getDefaultType()' is returning incorrect value", Optional.empty(),
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.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.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+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.util.BaseConstraints;
import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
@Test
public void integerTypeTest() {
- final IntegerTypeDefinition integerTypeDefinition8 = BaseTypes.int8Type();
- final IntegerTypeDefinition integerTypeDefinition16 = BaseTypes.int16Type();
- final IntegerTypeDefinition integerTypeDefinition32 = BaseTypes.int32Type();
- final IntegerTypeDefinition integerTypeDefinition64 = BaseTypes.int64Type();
+ final Int8TypeDefinition integerTypeDefinition8 = BaseTypes.int8Type();
+ final Int16TypeDefinition integerTypeDefinition16 = BaseTypes.int16Type();
+ final Int32TypeDefinition integerTypeDefinition32 = BaseTypes.int32Type();
+ final Int64TypeDefinition integerTypeDefinition64 = BaseTypes.int64Type();
assertTrue(BaseTypes.isInt8(integerTypeDefinition8));
assertTrue(BaseTypes.isInt16(integerTypeDefinition16));
assertTrue(BaseTypes.isInt32(integerTypeDefinition32));
testInstance(BaseInt32Type.INSTANCE, integerTypeDefinition32);
testInstance(BaseInt64Type.INSTANCE, integerTypeDefinition64);
- final RestrictedIntegerType restrictedIntegerType1 = (RestrictedIntegerType)RestrictedTypes.newIntegerBuilder(
+ final RestrictedInt8Type restrictedIntegerType1 = (RestrictedInt8Type)RestrictedTypes.newInt8Builder(
integerTypeDefinition8, SCHEMA_PATH).buildType();
- final RestrictedIntegerType restrictedIntegerType2 = (RestrictedIntegerType)RestrictedTypes.newIntegerBuilder(
+ final RestrictedInt8Type restrictedIntegerType2 = (RestrictedInt8Type)RestrictedTypes.newInt8Builder(
BaseInt8Type.INSTANCE, SCHEMA_PATH).buildType();
hashCodeEqualsToStringTest(restrictedIntegerType1, restrictedIntegerType2);
- final UnsignedIntegerTypeDefinition integerTypeDefinitionu8 = BaseTypes.uint8Type();
- final UnsignedIntegerTypeDefinition integerTypeDefinitionu16 = BaseTypes.uint16Type();
- final UnsignedIntegerTypeDefinition integerTypeDefinitionu32 = BaseTypes.uint32Type();
- final UnsignedIntegerTypeDefinition integerTypeDefinitionu64 = BaseTypes.uint64Type();
+ final Uint8TypeDefinition integerTypeDefinitionu8 = BaseTypes.uint8Type();
+ final Uint16TypeDefinition integerTypeDefinitionu16 = BaseTypes.uint16Type();
+ final Uint32TypeDefinition integerTypeDefinitionu32 = BaseTypes.uint32Type();
+ final Uint64TypeDefinition integerTypeDefinitionu64 = BaseTypes.uint64Type();
assertTrue(BaseTypes.isUint8(integerTypeDefinitionu8));
assertTrue(BaseTypes.isUint16(integerTypeDefinitionu16));
assertTrue(BaseTypes.isUint32(integerTypeDefinitionu32));
testInstance(BaseUint32Type.INSTANCE, integerTypeDefinitionu32);
testInstance(BaseUint64Type.INSTANCE, BaseTypes.baseTypeOf(integerTypeDefinitionu64));
- final DerivedIntegerType derivedIntegerType1 = (DerivedIntegerType)DerivedTypes
+ final DerivedInt8Type derivedIntegerType1 = (DerivedInt8Type)DerivedTypes
.derivedTypeBuilder(integerTypeDefinition8, SCHEMA_PATH).build();
- final DerivedIntegerType derivedIntegerType2 = (DerivedIntegerType)DerivedTypes
+ final DerivedInt8Type derivedIntegerType2 = (DerivedInt8Type)DerivedTypes
.derivedTypeBuilder(BaseInt8Type.INSTANCE, SCHEMA_PATH).build();
hashCodeEqualsToStringTest(derivedIntegerType1, derivedIntegerType2);
- final DerivedUnsignedType derivedUnsignedType1 = (DerivedUnsignedType)DerivedTypes
+ final DerivedUint8Type derivedUnsignedType1 = (DerivedUint8Type)DerivedTypes
.derivedTypeBuilder(integerTypeDefinitionu8, SCHEMA_PATH).build();
- final DerivedUnsignedType derivedUnsignedType2 = (DerivedUnsignedType)DerivedTypes
+ final DerivedUint8Type derivedUnsignedType2 = (DerivedUint8Type)DerivedTypes
.derivedTypeBuilder(BaseUint8Type.INSTANCE, SCHEMA_PATH).build();
hashCodeEqualsToStringTest(derivedUnsignedType1, derivedUnsignedType2);
- final RestrictedUnsignedType restrictedUnsignedType1 = (RestrictedUnsignedType)RestrictedTypes
- .newUnsignedBuilder(integerTypeDefinitionu8, SCHEMA_PATH).buildType();
- final RestrictedUnsignedType restrictedUnsignedType2 = (RestrictedUnsignedType)RestrictedTypes
- .newUnsignedBuilder(BaseUint8Type.INSTANCE, SCHEMA_PATH).buildType();
+ final RestrictedUint8Type restrictedUnsignedType1 = (RestrictedUint8Type)RestrictedTypes
+ .newUint8Builder(integerTypeDefinitionu8, SCHEMA_PATH).buildType();
+ final RestrictedUint8Type restrictedUnsignedType2 = (RestrictedUint8Type)RestrictedTypes
+ .newUint8Builder(BaseUint8Type.INSTANCE, SCHEMA_PATH).buildType();
hashCodeEqualsToStringTest(restrictedUnsignedType1, restrictedUnsignedType2);
concreteBuilderTest(integerTypeDefinition8, derivedIntegerType1);
concreteBuilderTest(integerTypeDefinitionu8, derivedUnsignedType2);
final TypeDefinition<?> typeDefinition = lengthRestrictedTypeBuilder.buildType();
assertNotNull(typeDefinition);
- final IntegerTypeDefinition integerTypeDefinition8 = BaseTypes.int8Type();
- final RangeRestrictedTypeBuilder<?> rangeRestrictedTypeBuilder = RestrictedTypes
- .newIntegerBuilder(integerTypeDefinition8, SCHEMA_PATH);
+ final Int8TypeDefinition integerTypeDefinition8 = BaseTypes.int8Type();
+ final RangeRestrictedTypeBuilder<?> rangeRestrictedTypeBuilder = RestrictedTypes.newInt8Builder(
+ integerTypeDefinition8, SCHEMA_PATH);
rangeRestrictedTypeBuilder.setRangeConstraint(mock(ConstraintMetaDefinition.class), lengthArrayList);
final TypeDefinition<?> typeDefinition1 = rangeRestrictedTypeBuilder.buildType();
assertNotNull(typeDefinition1);
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.UnsignedIntegerTypeDefinition;
import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
} else if (baseType instanceof InstanceIdentifierTypeDefinition) {
return new InstanceIdentifierTypeEffectiveStatementImpl(ctx,
(InstanceIdentifierTypeDefinition) baseType);
- } else if (baseType instanceof IntegerTypeDefinition) {
- return new IntegerTypeEffectiveStatementImpl(ctx, (IntegerTypeDefinition) baseType);
+ } else if (baseType instanceof Int8TypeDefinition) {
+ return IntegerTypeEffectiveStatementImpl.create(ctx, (Int8TypeDefinition) baseType);
+ } else if (baseType instanceof Int16TypeDefinition) {
+ return IntegerTypeEffectiveStatementImpl.create(ctx, (Int16TypeDefinition) baseType);
+ } else if (baseType instanceof Int32TypeDefinition) {
+ return IntegerTypeEffectiveStatementImpl.create(ctx, (Int32TypeDefinition) baseType);
+ } else if (baseType instanceof Int64TypeDefinition) {
+ return IntegerTypeEffectiveStatementImpl.create(ctx, (Int64TypeDefinition) baseType);
} else if (baseType instanceof LeafrefTypeDefinition) {
return new LeafrefTypeEffectiveStatementImpl(ctx, (LeafrefTypeDefinition) baseType);
} else if (baseType instanceof StringTypeDefinition) {
return new StringTypeEffectiveStatementImpl(ctx, (StringTypeDefinition) baseType);
+ } else if (baseType instanceof Uint8TypeDefinition) {
+ return UnsignedIntegerTypeEffectiveStatementImpl.create(ctx, (Uint8TypeDefinition) baseType);
+ } else if (baseType instanceof Uint16TypeDefinition) {
+ return UnsignedIntegerTypeEffectiveStatementImpl.create(ctx, (Uint16TypeDefinition) baseType);
+ } else if (baseType instanceof Uint32TypeDefinition) {
+ return UnsignedIntegerTypeEffectiveStatementImpl.create(ctx, (Uint32TypeDefinition) baseType);
+ } else if (baseType instanceof Uint64TypeDefinition) {
+ return UnsignedIntegerTypeEffectiveStatementImpl.create(ctx, (Uint64TypeDefinition) baseType);
} else if (baseType instanceof UnionTypeDefinition) {
return new UnionTypeEffectiveStatementImpl(ctx, (UnionTypeDefinition) baseType);
- } else if (baseType instanceof UnsignedIntegerTypeDefinition) {
- return new UnsignedIntegerTypeEffectiveStatementImpl(ctx, (UnsignedIntegerTypeDefinition) baseType);
} else {
throw new IllegalStateException("Unhandled base type " + baseType);
}
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+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.util.type.InvalidRangeConstraintException;
import org.opendaylight.yangtools.yang.model.util.type.RangeRestrictedTypeBuilder;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffectiveStatementImpl;
-public final class IntegerTypeEffectiveStatementImpl extends
- DeclaredEffectiveStatementBase<String,TypeStatement> implements TypeEffectiveStatement<TypeStatement> {
+public final class IntegerTypeEffectiveStatementImpl<T extends IntegerTypeDefinition<?, T>> extends
+ DeclaredEffectiveStatementBase<String, TypeStatement> implements TypeEffectiveStatement<TypeStatement> {
- private final IntegerTypeDefinition typeDefinition;
+ private final T typeDefinition;
- public IntegerTypeEffectiveStatementImpl(
+ private IntegerTypeEffectiveStatementImpl(
final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
- final IntegerTypeDefinition baseType) {
+ final RangeRestrictedTypeBuilder<T> builder) {
super(ctx);
- final RangeRestrictedTypeBuilder<IntegerTypeDefinition> builder =
- RestrictedTypes.newIntegerBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx));
-
for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
if (stmt instanceof RangeEffectiveStatementImpl) {
final RangeEffectiveStatementImpl range = (RangeEffectiveStatementImpl) stmt;
}
}
+ public static IntegerTypeEffectiveStatementImpl<Int8TypeDefinition> create(
+ final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
+ final Int8TypeDefinition baseType) {
+ return new IntegerTypeEffectiveStatementImpl<>(ctx, RestrictedTypes.newInt8Builder(baseType,
+ TypeUtils.typeEffectiveSchemaPath(ctx)));
+ }
+
+ public static IntegerTypeEffectiveStatementImpl<Int16TypeDefinition> create(
+ final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
+ final Int16TypeDefinition baseType) {
+ return new IntegerTypeEffectiveStatementImpl<>(ctx, RestrictedTypes.newInt16Builder(baseType,
+ TypeUtils.typeEffectiveSchemaPath(ctx)));
+ }
+
+ public static IntegerTypeEffectiveStatementImpl<Int32TypeDefinition> create(
+ final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
+ final Int32TypeDefinition baseType) {
+ return new IntegerTypeEffectiveStatementImpl<>(ctx, RestrictedTypes.newInt32Builder(baseType,
+ TypeUtils.typeEffectiveSchemaPath(ctx)));
+ }
+
+ public static IntegerTypeEffectiveStatementImpl<Int64TypeDefinition> create(
+ final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
+ final Int64TypeDefinition baseType) {
+ return new IntegerTypeEffectiveStatementImpl<>(ctx, RestrictedTypes.newInt64Builder(baseType,
+ TypeUtils.typeEffectiveSchemaPath(ctx)));
+ }
+
@Nonnull
@Override
- public IntegerTypeDefinition getTypeDefinition() {
+ public T getTypeDefinition() {
return typeDefinition;
}
}
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+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;
import org.opendaylight.yangtools.yang.model.util.type.RangeRestrictedTypeBuilder;
import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffectiveStatementImpl;
-public final class UnsignedIntegerTypeEffectiveStatementImpl extends
+public final class UnsignedIntegerTypeEffectiveStatementImpl<T extends UnsignedIntegerTypeDefinition<?, T>> extends
DeclaredEffectiveStatementBase<String, TypeStatement> implements TypeEffectiveStatement<TypeStatement> {
- private final UnsignedIntegerTypeDefinition typeDefinition;
+ private final T typeDefinition;
- public UnsignedIntegerTypeEffectiveStatementImpl(
+ private UnsignedIntegerTypeEffectiveStatementImpl(
final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
- final UnsignedIntegerTypeDefinition baseType) {
+ final RangeRestrictedTypeBuilder<T> builder) {
super(ctx);
- final RangeRestrictedTypeBuilder<UnsignedIntegerTypeDefinition> builder =
- RestrictedTypes.newUnsignedBuilder(baseType, TypeUtils.typeEffectiveSchemaPath(ctx));
-
for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
if (stmt instanceof RangeEffectiveStatementImpl) {
final RangeEffectiveStatementImpl rangeStmt = (RangeEffectiveStatementImpl)stmt;
typeDefinition = builder.build();
}
+ public static UnsignedIntegerTypeEffectiveStatementImpl<Uint8TypeDefinition> create(
+ final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
+ final Uint8TypeDefinition baseType) {
+ return new UnsignedIntegerTypeEffectiveStatementImpl<>(ctx, RestrictedTypes.newUint8Builder(baseType,
+ TypeUtils.typeEffectiveSchemaPath(ctx)));
+ }
+
+ public static UnsignedIntegerTypeEffectiveStatementImpl<Uint16TypeDefinition> create(
+ final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
+ final Uint16TypeDefinition baseType) {
+ return new UnsignedIntegerTypeEffectiveStatementImpl<>(ctx, RestrictedTypes.newUint16Builder(baseType,
+ TypeUtils.typeEffectiveSchemaPath(ctx)));
+ }
+
+ public static UnsignedIntegerTypeEffectiveStatementImpl<Uint32TypeDefinition> create(
+ final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
+ final Uint32TypeDefinition baseType) {
+ return new UnsignedIntegerTypeEffectiveStatementImpl<>(ctx, RestrictedTypes.newUint32Builder(baseType,
+ TypeUtils.typeEffectiveSchemaPath(ctx)));
+ }
+
+ public static UnsignedIntegerTypeEffectiveStatementImpl<Uint64TypeDefinition> create(
+ final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
+ final Uint64TypeDefinition baseType) {
+ return new UnsignedIntegerTypeEffectiveStatementImpl<>(ctx, RestrictedTypes.newUint64Builder(baseType,
+ TypeUtils.typeEffectiveSchemaPath(ctx)));
+ }
+
@Nonnull
@Override
public UnsignedIntegerTypeDefinition getTypeDefinition() {
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
-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.LeafrefTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
(LeafrefTypeDefinition) leafRefNode2.getType(), context, leafRefNode2);
assertTrue(baseTypeForLeafRef instanceof BinaryTypeDefinition);
- assertTrue(baseTypeForLeafRef2 instanceof IntegerTypeDefinition);
+ assertTrue(baseTypeForLeafRef2 instanceof Int16TypeDefinition);
}
}
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
public class Bug6771Test {
private static void verifyLeafType(final SchemaNode schemaNode) {
assertTrue(schemaNode instanceof LeafSchemaNode);
- assertTrue(((LeafSchemaNode) schemaNode).getType() instanceof UnsignedIntegerTypeDefinition);
+ assertTrue(((LeafSchemaNode) schemaNode).getType() instanceof Uint32TypeDefinition);
}
}
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
QName.create(barModule.getQNameModule(), "my-leaf"));
assertNotNull(myLeaf);
- assertTrue(myLeaf.getType() instanceof UnsignedIntegerTypeDefinition);
+ assertTrue(myLeaf.getType() instanceof Uint32TypeDefinition);
assertEquals(Optional.of("bytes"), myLeaf.getType().getUnits());
assertEquals(Optional.of("10"), myLeaf.getType().getDefaultValue());
final LeafSchemaNode myAugLeaf = (LeafSchemaNode) myCont.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-aug-leaf"));
assertNotNull(myAugLeaf);
- assertTrue(myAugLeaf.getType() instanceof UnsignedIntegerTypeDefinition);
+ assertTrue(myAugLeaf.getType() instanceof Uint32TypeDefinition);
assertEquals(Optional.of("seconds"), myAugLeaf.getType().getUnits());
assertEquals(Optional.of("new-def-val"), myAugLeaf.getType().getDefaultValue());
assertEquals(1, myAugLeaf.getUnknownSchemaNodes().size());
final LeafSchemaNode myUsedLeaf = (LeafSchemaNode) myCont.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-used-leaf"));
assertNotNull(myUsedLeaf);
- assertTrue(myUsedLeaf.getType() instanceof UnsignedIntegerTypeDefinition);
+ assertTrue(myUsedLeaf.getType() instanceof Uint32TypeDefinition);
assertEquals(Optional.of("weeks"), myUsedLeaf.getType().getUnits());
assertEquals(Optional.of("new-def-val"), myUsedLeaf.getType().getDefaultValue());
assertEquals(1, myUsedLeaf.getUnknownSchemaNodes().size());
import org.opendaylight.yangtools.yang.model.api.Deviation;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
assertEquals(12, deviate.getDeviatedMaxElements().intValue());
} else if (DeviateKind.REPLACE.equals(deviate.getDeviateType())) {
assertEquals(5, deviate.getDeviatedMinElements().intValue());
- assertTrue(deviate.getDeviatedType() instanceof UnsignedIntegerTypeDefinition);
+ assertTrue(deviate.getDeviatedType() instanceof Uint32TypeDefinition);
} else {
assertEquals(2, deviate.getDeviatedMusts().size());
assertEquals("minutes", deviate.getDeviatedUnits());
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+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;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, version.getPath());
- assertTrue(version.getType() instanceof UnsignedIntegerTypeDefinition);
+ assertTrue(version.getType() instanceof Uint8TypeDefinition);
assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
assertTrue(version.isAddedByUses());
assertTrue(version.isAugmenting());
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
-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.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
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.type.BaseTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
final LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(),
"ifIndex"));
assertEquals(ifEntry.getKeyDefinition().get(0), ifIndex.getQName());
- assertTrue(ifIndex.getType() instanceof UnsignedIntegerTypeDefinition);
+ assertTrue(ifIndex.getType() instanceof Uint32TypeDefinition);
assertEquals(Optional.of("minutes"), ifIndex.getType().getUnits());
final LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(),
"ifMtu"));
final LeafSchemaNode int32Leaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
"int32-leaf"));
- final IntegerTypeDefinition leafType = (IntegerTypeDefinition) int32Leaf.getType();
+ final Int32TypeDefinition leafType = (Int32TypeDefinition) int32Leaf.getType();
assertEquals(QName.create(FOO, "int32-ext2"), leafType.getQName());
assertEquals(Optional.of("mile"), leafType.getUnits());
assertEquals(Optional.of("11"), leafType.getDefaultValue());
assertEquals(12, range.lowerEndpoint().intValue());
assertEquals(20, range.upperEndpoint().intValue());
- final IntegerTypeDefinition firstBaseType = leafType.getBaseType();
+ final Int32TypeDefinition firstBaseType = leafType.getBaseType();
assertEquals(QName.create(BAR, "int32-ext2"), firstBaseType.getQName());
assertEquals(Optional.of("mile"), firstBaseType.getUnits());
assertEquals(Optional.of("11"), firstBaseType.getDefaultValue());
assertEquals(11, baseTypeRange2.lowerEndpoint().intValue());
assertEquals(20, baseTypeRange2.upperEndpoint().intValue());
- final IntegerTypeDefinition secondBaseType = firstBaseType.getBaseType();
+ final Int32TypeDefinition secondBaseType = firstBaseType.getBaseType();
final QName baseQName = secondBaseType.getQName();
assertEquals("int32-ext1", baseQName.getLocalName());
assertEquals(BAR, baseQName.getModule());
final List<TypeDefinition<?>> unionTypes = unionType.getTypes();
assertEquals(2, unionTypes.size());
- final IntegerTypeDefinition unionType1 = (IntegerTypeDefinition) unionTypes.get(0);
+ final Int16TypeDefinition unionType1 = (Int16TypeDefinition) unionTypes.get(0);
assertEquals(QName.create(BAR, "my-union"), baseType.getQName());
assertEquals(Optional.empty(), unionType1.getUnits());
assertEquals(Optional.empty(), unionType1.getDefaultValue());
final UnionTypeDefinition myUnionBase = myUnion.getBaseType();
final List<TypeDefinition<?>> myUnionBaseTypes = myUnionBase.getTypes();
assertEquals(2, myUnionBaseTypes.size());
- assertTrue(myUnionBaseTypes.get(0) instanceof IntegerTypeDefinition);
+ assertTrue(myUnionBaseTypes.get(0) instanceof Int16TypeDefinition);
assertEquals(BaseTypes.int32Type(), myUnionBaseTypes.get(1));
- final IntegerTypeDefinition int16Ext = (IntegerTypeDefinition) myUnionBaseTypes.get(0);
+ final Int16TypeDefinition int16Ext = (Int16TypeDefinition) myUnionBaseTypes.get(0);
assertEquals(QName.create(BAR, "int16"), int16Ext.getQName());
assertEquals(Optional.empty(), int16Ext.getUnits());
assertEquals(Optional.empty(), int16Ext.getDefaultValue());
final Set<TypeDefinition<?>> types = bar.getTypeDefinitions();
// int32-ext1
- final IntegerTypeDefinition int32ext1 = (IntegerTypeDefinition) TestUtils.findTypedef(types, "int32-ext1");
+ final Int32TypeDefinition int32ext1 = (Int32TypeDefinition) TestUtils.findTypedef(types, "int32-ext1");
final QName int32TypedefQName = QName.create(BAR, "int32-ext1");
assertEquals(int32TypedefQName, int32ext1.getQName());
assertFalse(typePathIt.hasNext());
// int32-ext1/int32
- final IntegerTypeDefinition int32 = int32ext1.getBaseType();
+ final Int32TypeDefinition int32 = int32ext1.getBaseType();
assertEquals(BaseTypes.int32Type(), int32);
}
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
final LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(QName.create(module.getQNameModule(),
"id"));
- assertTrue(leaf.getType() instanceof UnsignedIntegerTypeDefinition);
- final UnsignedIntegerTypeDefinition leafType = (UnsignedIntegerTypeDefinition) leaf.getType();
+ assertTrue(leaf.getType() instanceof Uint16TypeDefinition);
+ final Uint16TypeDefinition leafType = (Uint16TypeDefinition) leaf.getType();
QName qname = leafType.getQName();
assertEquals(URI.create("urn:simple.demo.test1"), qname.getNamespace());
assertEquals(Revision.ofNullable("2013-06-18"), qname.getRevision());
assertEquals("port-number", qname.getLocalName());
- final UnsignedIntegerTypeDefinition leafBaseType = leafType.getBaseType();
+ final Uint16TypeDefinition leafBaseType = leafType.getBaseType();
qname = leafBaseType.getQName();
assertEquals(URI.create("urn:ietf:params:xml:ns:yang:ietf-inet-types"), qname.getNamespace());
assertEquals(Revision.ofNullable("2010-09-24"), qname.getRevision());
assertEquals("port-number", qname.getLocalName());
- final UnsignedIntegerTypeDefinition dscpExt = (UnsignedIntegerTypeDefinition) TestUtils.findTypedef(
- module.getTypeDefinitions(), "dscp-ext");
+ final Uint8TypeDefinition dscpExt = (Uint8TypeDefinition) TestUtils.findTypedef(module.getTypeDefinitions(),
+ "dscp-ext");
final Set<? extends Range<?>> ranges = dscpExt.getRangeConstraint().get().getAllowedRanges().asRanges();
assertEquals(1, ranges.size());
final Range<?> range = ranges.iterator().next();
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
TypeDefinition<?> myLeaf2Type = ((LeafSchemaNode) myLeaf2Node).getType();
assertTrue(myLeafType instanceof StringTypeDefinition);
- assertTrue(myLeaf2Type instanceof IntegerTypeDefinition);
+ assertTrue(myLeaf2Type instanceof Int32TypeDefinition);
final LengthConstraint lengthConstraint =
((StringTypeDefinition) myLeafType).getLengthConstraint().get();
assertEquals(Optional.of("pattern constraint error-app-tag"), patternConstraint.getErrorAppTag());
assertEquals(Optional.of("pattern constraint error-app-message"), patternConstraint.getErrorMessage());
- RangeConstraint<?> rangeConstraint = ((IntegerTypeDefinition) myLeaf2Type).getRangeConstraint().get();
+ RangeConstraint<?> rangeConstraint = ((Int32TypeDefinition) myLeaf2Type).getRangeConstraint().get();
assertEquals(1, rangeConstraint.getAllowedRanges().asRanges().size());
assertEquals(Optional.of("range constraint error-app-tag"), rangeConstraint.getErrorAppTag());