Base yang types can not be restricted now. Every restriction causes creation of new ExtendedType with default yang type as base type.
Updated tests.
Change-Id: I04b2a0a069dcf4f7b3a3d1220c742fed047cba3a
Signed-off-by: Martin Vitez <mvitez@cisco.com>
*
*/
public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
-
private final QName name;
private final SchemaPath path;
private final String description;
private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.2";
-
private final String units;
private final List<RangeConstraint> rangeStatements;
- protected AbstractSignedInteger(final QName name, final String description,
- final Number minRange, final Number maxRange, final String units) {
- this.name = name;
- this.description = description;
- this.path = BaseTypes.schemaPath(name);
- this.units = units;
- this.rangeStatements = new ArrayList<RangeConstraint>();
- final String rangeDescription = "Integer values between " + minRange
- + " and " + maxRange + ", inclusively.";
- this.rangeStatements.add(BaseConstraints.rangeConstraint(minRange,
- maxRange, rangeDescription,
- "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
- }
-
/**
* @param name
* @param description
private final SchemaPath path;
private final String description;
private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.2";
-
private final String units;
private final List<RangeConstraint> rangeStatements;
- protected AbstractUnsignedInteger(final QName name,
- final String description, final Number minRange,
- final Number maxRange, final String units) {
- this.name = name;
- this.description = description;
- this.path = BaseTypes.schemaPath(name);
- this.units = units;
- this.rangeStatements = new ArrayList<RangeConstraint>();
- final String rangeDescription = "Integer values between " + minRange
- + " and " + maxRange + ", inclusively.";
- this.rangeStatements.add(BaseConstraints.rangeConstraint(minRange,
- maxRange, rangeDescription,
- "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
- }
-
/**
*
* @param actualPath
* @see BinaryTypeDefinition
*/
public final class BinaryType implements BinaryTypeDefinition {
-
private final QName name = BaseTypes.constructQName("binary");
private final SchemaPath path;
private final String description = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.8";
private final BinaryTypeDefinition baseType;
- private List<Byte> bytes;
+ private final List<Byte> bytes;
private final List<LengthConstraint> lengthConstraints;
- private String units = "";
-
- private BinaryType() {
- super();
+ private final String units = "";
+ public BinaryType(final SchemaPath path) {
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
""));
this.lengthConstraints = Collections.unmodifiableList(constraints);
this.bytes = Collections.emptyList();
- this.path = BaseTypes.schemaPath(name);
+ this.path = path;
this.baseType = this;
}
- public BinaryType(final SchemaPath path) {
- super();
-
+ public BinaryType(final SchemaPath path, final List<Byte> bytes) {
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
""));
this.lengthConstraints = Collections.unmodifiableList(constraints);
- this.bytes = Collections.emptyList();
- this.path = path;
- this.baseType = new BinaryType();
- }
-
- /**
- *
- *
- * @param bytes
- * @param lengthConstraints
- * @param units
- */
- public BinaryType(final SchemaPath path, final List<Byte> bytes,
- final List<LengthConstraint> lengthConstraints, final String units) {
- super();
-
- if ((lengthConstraints == null) || (lengthConstraints.isEmpty())) {
- final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
- constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE,
- "", ""));
- this.lengthConstraints = Collections.unmodifiableList(constraints);
- } else {
- this.lengthConstraints = Collections
- .unmodifiableList(lengthConstraints);
- }
-
- this.path = path;
this.bytes = Collections.unmodifiableList(bytes);
- this.units = units;
- this.baseType = new BinaryType();
+ this.path = path;
+ this.baseType = this;
}
/*
* @see BitsTypeDefinition
*/
public final class BitsType implements BitsTypeDefinition {
-
private final QName name = BaseTypes.constructQName("bits");
private final SchemaPath path;
private final String description = "The bits built-in type represents a bit set. "
private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
private final BitsTypeDefinition baseType;
private final List<Bit> bits;
- private String units = "";
+ private final String units = "";
/**
* Default constructor. <br>
* Instantiates Bits type as empty bits list.
*/
- private BitsType() {
- super();
- this.bits = Collections.emptyList();
- this.path = BaseTypes.schemaPath(name);
- this.baseType = this;
- }
-
public BitsType(final SchemaPath path) {
super();
this.bits = Collections.emptyList();
this.path = path;
- this.baseType = new BitsType();
+ this.baseType = this;
}
/**
public BitsType(final SchemaPath path, final List<Bit> bits) {
super();
this.bits = Collections.unmodifiableList(bits);
- this.units = "";
- this.path = path;
- this.baseType = new BitsType();
- }
-
- /**
- * Constructor with explicit definition of bits assigned to BitsType and
- * Units. <br>
- * The default value of Bits Type is List of bits.
- *
- * @param bits
- * The bits assigned for Bits Type
- * @param units
- * units for bits type
- */
- public BitsType(final SchemaPath path, List<Bit> bits, String units) {
- super();
- this.bits = Collections.unmodifiableList(bits);
- this.units = units;
this.path = path;
- this.baseType = new BitsType();
+ this.baseType = this;
}
/*
* @see BooleanTypeDefinition
*/
public final class BooleanType implements BooleanTypeDefinition {
-
private final QName name = BaseTypes.constructQName("boolean");
private final SchemaPath path;
private final String description = "The boolean built-in type represents a boolean value.";
private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.5";
private final BooleanTypeDefinition baseType;
private final Boolean defaultValue;
- private String units = "";
+ private final String units = "";
/**
* Default constructor with default value set to "false".
*/
- private BooleanType() {
- super();
- this.defaultValue = false;
- this.path = BaseTypes.schemaPath(name);
- this.baseType = this;
- }
-
public BooleanType(final SchemaPath path) {
super();
this.defaultValue = false;
this.path = path;
- this.baseType = new BooleanType();
+ this.baseType = this;
}
/**
super();
this.defaultValue = defaultValue;
this.path = path;
- this.baseType = new BooleanType();
- }
-
- /**
- * Boolean Type constructor.
- *
- * @param defaultValue
- * Default Value
- * @param units
- * Units
- */
- public BooleanType(final SchemaPath path, final Boolean defaultValue, final String units) {
- super();
- this.defaultValue = defaultValue;
- this.units = units;
- this.path = path;
- this.baseType = new BooleanType();
+ this.baseType = this;
}
/*
* @see DecimalTypeDefinition
*/
public final class Decimal64 implements DecimalTypeDefinition {
-
private final QName name = BaseTypes.constructQName("decimal64");
private final SchemaPath path;
- private String units = "";
- private BigDecimal defaultValue = null;
+ private final String units = "";
+ private final BigDecimal defaultValue = null;
private final String description = "The decimal64 type represents a subset of the real numbers, which can "
+ "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can "
* If the fraction digits are not defined inner the definition boundaries
* the constructor will throw {@link IllegalArgumentException}
*
+ * @param path
* @param fractionDigits
* integer between 1 and 18 inclusively
*
* @see DecimalTypeDefinition
* @exception IllegalArgumentException
*/
- private Decimal64(final Integer fractionDigits) {
- if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
- throw new IllegalArgumentException(
- "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
- }
- this.fractionDigits = fractionDigits;
- this.rangeStatements = defaultRangeStatements();
- this.path = BaseTypes.schemaPath(name);
- this.baseType = this;
- }
-
public Decimal64(final SchemaPath path, final Integer fractionDigits) {
- super();
if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
throw new IllegalArgumentException(
"The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
this.fractionDigits = fractionDigits;
rangeStatements = defaultRangeStatements();
this.path = path;
- this.baseType = new Decimal64(fractionDigits);
- }
-
- /**
- * Decimal64 Type Constructor. <br>
- *
- * If parameter <code>Range Statements</code> is <code>null</code> or
- * defined as <code>empty List</code> the constructor automatically assigns
- * the boundaries as min and max value defined for Decimal64 in <a
- * href="https://tools.ietf.org/html/rfc6020#section-9.3">[RFC-6020] The
- * decimal64 Built-In Type</a> <br>
- * <br>
- * The fractions digits MUST be defined as integer between 1 and 18
- * inclusively as defined interface {@link DecimalTypeDefinition} <br>
- * If the fraction digits are not defined inner the definition boundaries
- * the constructor will throw {@link IllegalArgumentException}
- *
- * @param actualPath
- * @param namespace
- * @param revision
- * @param rangeStatements
- * Range Constraint Statements
- * @param fractionDigits
- * integer between 1 and 18 inclusively
- * @exception IllegalArgumentException
- */
- public Decimal64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
- Integer fractionDigits) {
- super();
- if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
- throw new IllegalArgumentException(
- "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
- }
- if (rangeStatements == null || rangeStatements.isEmpty()) {
- this.rangeStatements = defaultRangeStatements();
- } else {
- this.rangeStatements = Collections
- .unmodifiableList(rangeStatements);
- }
- this.fractionDigits = fractionDigits;
- this.path = path;
- this.baseType = new Decimal64(fractionDigits);
- }
-
- /**
- * Decimal64 Type Constructor. <br>
- * If parameter <code>Range Statements</code> is <code>null</code> or
- * defined as <code>empty List</code> the constructor automatically assigns
- * the boundaries as min and max value defined for Decimal64 in <a
- * href="https://tools.ietf.org/html/rfc6020#section-9.3">[RFC-6020] The
- * decimal64 Built-In Type</a> <br>
- * <br>
- * The fractions digits MUST be defined as integer between 1 and 18
- * inclusively as defined interface {@link DecimalTypeDefinition} <br>
- * If the fraction digits are not defined inner the definition boundaries
- * the constructor will throw {@link IllegalArgumentException}
- *
- * @param actualPath
- * @param namespace
- * @param revision
- * @param units
- * units associated with the type
- * @param defaultValue
- * Default Value for type
- * @param rangeStatements
- * Range Constraint Statements
- * @param fractionDigits
- * integer between 1 and 18 inclusively
- */
- public Decimal64(final SchemaPath path, final String units,
- final BigDecimal defaultValue,
- final List<RangeConstraint> rangeStatements,
- final Integer fractionDigits) {
- super();
- if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
- throw new IllegalArgumentException(
- "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
- }
-
- if (rangeStatements == null || rangeStatements.isEmpty()) {
- this.rangeStatements = defaultRangeStatements();
-
- } else {
- this.rangeStatements = Collections
- .unmodifiableList(rangeStatements);
- }
- this.units = units;
- this.defaultValue = defaultValue;
- this.fractionDigits = fractionDigits;
- this.path = path;
- this.baseType = new Decimal64(fractionDigits);
+ this.baseType = this;
}
/**
import org.opendaylight.controller.yang.model.api.type.EmptyTypeDefinition;
public final class EmptyType implements EmptyTypeDefinition {
-
private final QName name = BaseTypes.constructQName("empty");
private final SchemaPath path;
private final String description = "The empty built-in type represents a leaf that does not have any value, it conveys information by its presence or absence.";
private final String reference = "https://tools.ietf.org/html/rfc6020#page-131";
private final EmptyTypeDefinition baseType;
- private EmptyType() {
- path = BaseTypes.schemaPath(name);
- this.baseType = this;
- }
-
public EmptyType(final SchemaPath path) {
this.path = path;
- this.baseType = new EmptyType();
+ this.baseType = this;
}
@Override
* @see EnumTypeDefinition
*/
public final class EnumerationType implements EnumTypeDefinition {
-
private final QName name = BaseTypes.constructQName("enumeration");
private final SchemaPath path;
private final String description = "The enumeration built-in type represents values from a set of assigned names.";
private final EnumPair defaultEnum;
private final List<EnumPair> enums;
- private String units = "";
+ private final String units = "";
private final EnumTypeDefinition baseType;
- private EnumerationType(final List<EnumPair> enums) {
- this.path = BaseTypes.schemaPath(name);
- this.enums = Collections.unmodifiableList(enums);
- this.defaultEnum = null;
- baseType = this;
- }
-
public EnumerationType(final SchemaPath path, final List<EnumPair> enums) {
super();
this.path = path;
this.enums = Collections.unmodifiableList(enums);
this.defaultEnum = null;
- baseType = new EnumerationType(enums);
+ this.baseType = this;
}
public EnumerationType(final SchemaPath path, final EnumPair defaultEnum,
- final List<EnumPair> enums, final String units) {
+ final List<EnumPair> enums) {
super();
this.path = path;
- baseType = new EnumerationType(enums);
+ this.baseType = this;
this.defaultEnum = defaultEnum;
this.enums = Collections.unmodifiableList(enums);
- this.units = units;
}
/*
* @see IdentityrefTypeDefinition\r
*/\r
public final class IdentityrefType implements IdentityrefTypeDefinition {\r
-\r
private final QName name = BaseTypes.constructQName("identityref");\r
private final SchemaPath path;\r
private final String description = "The identityref type is used to reference an existing identity.";\r
private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.10";\r
private final IdentityrefTypeDefinition baseType;\r
-\r
private final QName identity;\r
-\r
- private String units = "";\r
-\r
- private IdentityrefType(QName identity) {\r
- this.identity = identity;\r
- this.path = BaseTypes.schemaPath(name);\r
- this.baseType = this;\r
- }\r
+ private final String units = "";\r
\r
public IdentityrefType(QName identity, SchemaPath schemaPath) {\r
this.identity = identity;\r
this.path = schemaPath;\r
- this.baseType = new IdentityrefType(identity);\r
+ this.baseType = this;\r
}\r
\r
@Override\r
* @see InstanceIdentifierTypeDefinition
*/
public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
-
private static final QName name = BaseTypes
.constructQName("instance-identifier");
private static final String description = "The instance-identifier built-in type is used to " +
private final InstanceIdentifierTypeDefinition baseType;
private final boolean requireInstance;
- private InstanceIdentifier(RevisionAwareXPath xpath, boolean requireInstance) {
- super();
- path = BaseTypes.schemaPath(name);
- this.xpath = xpath;
- this.requireInstance = requireInstance;
- this.baseType = this;
- }
-
public InstanceIdentifier(final SchemaPath path, RevisionAwareXPath xpath, boolean requireInstance) {
super();
this.path = path;
this.xpath = xpath;
this.requireInstance = requireInstance;
- this.baseType = new InstanceIdentifier(xpath, requireInstance);
+ this.baseType = this;
}
/*
*/
package org.opendaylight.controller.yang.model.util;
-import java.util.List;
-
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
/**
* Implementation of Yang int16 built-in type. <br>
* @see AbstractSignedInteger
*/
public final class Int16 extends AbstractSignedInteger {
-
private static final QName name = BaseTypes.constructQName("int16");
- private Short defaultValue = null;
+ private final Short defaultValue = null;
private static final String description = "int16 represents integer values between -32768 and 32767, inclusively.";
private final IntegerTypeDefinition baseType;
- private Int16() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = this;
- }
-
public Int16(final SchemaPath path) {
super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Int16();
-
- }
+ this.baseType = this;
- public Int16(final SchemaPath path,
- final List<RangeConstraint> rangeStatements, final String units,
- final Short defaultValue) {
- super(path, name, description, rangeStatements, units);
- this.defaultValue = defaultValue;
- this.baseType = new Int16();
}
@Override
*/
package org.opendaylight.controller.yang.model.util;
-import java.util.List;
-
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
/**
* Implementation of Yang int32 built-in type. <br>
*
*/
public final class Int32 extends AbstractSignedInteger {
-
private static final QName name = BaseTypes.constructQName("int32");
- private Integer defaultValue = null;
+ private final Integer defaultValue = null;
private static final String description = "int32 represents integer values between -2147483648 and 2147483647, inclusively.";
private final IntegerTypeDefinition baseType;
- private Int32() {
- super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
- this.baseType = this;
- }
-
public Int32(final SchemaPath path) {
super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
- this.baseType = new Int32();
- }
-
- public Int32(final SchemaPath path, final Integer defaultValue) {
- super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
- this.baseType = new Int32();
- this.defaultValue = defaultValue;
- }
-
- public Int32(final SchemaPath path,
- final List<RangeConstraint> rangeStatements, final String units,
- final Integer defaultValue) {
- super(path, name, description, rangeStatements, units);
- this.baseType = new Int32();
- this.defaultValue = defaultValue;
+ this.baseType = this;
}
/*
*/
package org.opendaylight.controller.yang.model.util;
-import java.util.List;
-
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
/**
* Implementation of Yang int64 built-in type. <br>
*
*/
public final class Int64 extends AbstractSignedInteger {
-
private static final QName name = BaseTypes.constructQName("int64");
- private Long defaultValue = null;
+ private final Long defaultValue = null;
private static final String description =
"int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.";
private final IntegerTypeDefinition baseType;
- private Int64() {
- super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
- this.baseType = this;
- }
-
public Int64(final SchemaPath path) {
super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
- this.baseType = new Int64();
- }
-
- public Int64(final SchemaPath path, final Long defaultValue) {
- super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
- this.baseType = new Int64();
- this.defaultValue = defaultValue;
- }
-
- public Int64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
- final String units, final Long defaultValue) {
- super(path, name, description, rangeStatements, units);
- this.baseType = new Int64();
- this.defaultValue = defaultValue;
+ this.baseType = this;
}
/*
*/
package org.opendaylight.controller.yang.model.util;
-import java.util.List;
-
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
/**
* Implementation of Yang int8 built-in type. <br>
* @see AbstractSignedInteger
*/
public final class Int8 extends AbstractSignedInteger {
-
private static final QName name = BaseTypes.constructQName("int8");
- private Byte defaultValue = null;
+ private final Byte defaultValue = null;
private static final String description = "represents integer values between -128 and 127, inclusively.";
private final IntegerTypeDefinition baseType;
- private Int8() {
- super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
- this.baseType = this;
- }
-
public Int8(final SchemaPath path) {
super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
- this.baseType = new Int8();
- }
-
- public Int8(final SchemaPath path, final Byte defaultValue) {
- super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
- this.baseType = new Int8();
- this.defaultValue = defaultValue;
- }
-
- public Int8(final SchemaPath path,
- final List<RangeConstraint> rangeStatements, final String units,
- final Byte defaultValue) {
- super(path, name, description, rangeStatements, units);
- this.baseType = new Int8();
- this.defaultValue = defaultValue;
+ this.baseType = this;
}
/*
private final String units = "";
private final LeafrefTypeDefinition baseType;
- private Leafref(final RevisionAwareXPath xpath) {
- this.xpath = xpath;
- this.path = BaseTypes.schemaPath(name);
- this.baseType = this;
- }
-
public Leafref(final SchemaPath path, final RevisionAwareXPath xpath) {
- super();
this.path = path;
this.xpath = xpath;
- baseType = new Leafref(xpath);
+ baseType = this;
}
/*
* @see StringTypeDefinition
*/
public final class StringType implements StringTypeDefinition {
-
private final QName name = BaseTypes.constructQName("string");
private final SchemaPath path;
- private String defaultValue = "";
+ private final String defaultValue = "";
private final String description = "";
private final String reference = "";
private final List<LengthConstraint> lengthStatements;
private final List<PatternConstraint> patterns;
- private String units = "";
+ private final String units = "";
private final StringTypeDefinition baseType;
- private StringType() {
- super();
- path = BaseTypes.schemaPath(name);
- final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
- constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
- lengthStatements = Collections.unmodifiableList(constraints);
- patterns = Collections.emptyList();
- baseType = this;
- }
-
/**
* Default Constructor.
*/
constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
lengthStatements = Collections.unmodifiableList(constraints);
patterns = Collections.emptyList();
- baseType = new StringType();
- }
-
- /**
- *
- * @param actualPath
- * @param namespace
- * @param revision
- * @param lengthStatements
- * @param patterns
- */
- public StringType(final SchemaPath path, final List<LengthConstraint> lengthStatements,
- final List<PatternConstraint> patterns) {
- super();
- this.path = path;
- if(lengthStatements == null || lengthStatements.size() == 0) {
- final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
- constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
- this.lengthStatements = Collections.unmodifiableList(constraints);
- } else {
- this.lengthStatements = Collections.unmodifiableList(lengthStatements);
- }
- this.patterns = Collections.unmodifiableList(patterns);
- baseType = new StringType();
- }
-
- /**
- *
- *
- * @param defaultValue
- * @param lengthStatements
- * @param patterns
- * @param units
- */
- public StringType(final SchemaPath path, final String defaultValue,
- final List<LengthConstraint> lengthStatements,
- final List<PatternConstraint> patterns, final String units) {
- super();
- this.path = path;
- this.defaultValue = defaultValue;
- if(lengthStatements == null || lengthStatements.size() == 0) {
- final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
- constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
- this.lengthStatements = Collections.unmodifiableList(constraints);
- } else {
- this.lengthStatements = Collections.unmodifiableList(lengthStatements);
- }
- this.patterns = Collections.unmodifiableList(patterns);
- this.units = units;
- this.baseType = new StringType();
+ baseType = this;
}
/*
*/
package org.opendaylight.controller.yang.model.util;
-import java.util.List;
-
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
/**
*
*/
public final class Uint16 extends AbstractUnsignedInteger {
-
private static final QName name = BaseTypes.constructQName("uint16");
private Integer defaultValue = null;
private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
- private Uint16() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = this;
- }
-
public Uint16(final SchemaPath path) {
super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Uint16();
- }
-
- public Uint16(final SchemaPath path, final Integer defaultValue) {
- super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Uint16();
- this.defaultValue = defaultValue;
- }
-
- public Uint16(final SchemaPath path, final List<RangeConstraint> rangeStatements,
- final String units, final Integer defaultValue) {
- super(path, name, description, rangeStatements, units);
- this.baseType = new Uint16();
- this.defaultValue = defaultValue;
+ this.baseType = this;
}
/*
*/
package org.opendaylight.controller.yang.model.util;
-import java.util.List;
-
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
/**
*
*/
public final class Uint32 extends AbstractUnsignedInteger {
-
private static final QName name = BaseTypes.constructQName("uint32");
- private Long defaultValue = null;
+ private final Long defaultValue = null;
private static final String description = "uint32 represents integer values between 0 and 4294967295, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
- private Uint32() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = this;
- }
-
public Uint32(final SchemaPath path) {
super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Uint32();
- }
-
- public Uint32(final SchemaPath path, final Long defaultValue) {
- super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Uint32();
- this.defaultValue = defaultValue;
- }
-
- public Uint32(final SchemaPath path, final List<RangeConstraint> rangeStatements,
- final String units, final Long defaultValue) {
- super(path, name, description, rangeStatements, units);
- this.baseType = new Uint32();
- this.defaultValue = defaultValue;
+ this.baseType = this;
}
/*
package org.opendaylight.controller.yang.model.util;
import java.math.BigInteger;
-import java.util.List;
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
/**
*
*/
public final class Uint64 extends AbstractUnsignedInteger {
-
private static final QName name = BaseTypes.constructQName("uint64");
-
- private BigInteger defaultValue = null;
+ private final BigInteger defaultValue = null;
private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
- private Uint64() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = this;
- }
-
public Uint64(final SchemaPath path) {
super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Uint64();
- }
-
- public Uint64(final SchemaPath path, final BigInteger defaultValue) {
- super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Uint64();
- this.defaultValue = defaultValue;
- }
-
- public Uint64(final SchemaPath path,
- final List<RangeConstraint> rangeStatements, final String units,
- final BigInteger defaultValue) {
- super(path, name, description, rangeStatements, units);
- this.baseType = new Uint64();
- this.defaultValue = defaultValue;
+ this.baseType = this;
}
/*
*/
package org.opendaylight.controller.yang.model.util;
-import java.util.List;
-
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
/**
public final class Uint8 extends AbstractUnsignedInteger {
private static final QName name = BaseTypes.constructQName("uint8");
- private Short defaultValue = null;
+ private final Short defaultValue = null;
private static final String description =
"uint8 represents integer values between 0 and 255, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
- private Uint8() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = this;
- }
-
public Uint8(final SchemaPath path) {
super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Uint8();
- }
-
- public Uint8(final SchemaPath path, final Short defaultValue) {
- super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
- this.baseType = new Uint8();
- this.defaultValue = defaultValue;
- }
-
- public Uint8(final SchemaPath path, final List<RangeConstraint> rangeStatements,
- final String units, final Short defaultValue) {
- super(path, name, description, rangeStatements, units);
- this.baseType = new Uint8();
- this.defaultValue = defaultValue;
+ this.baseType = this;
}
/*
String typeName) {\r
TypeDefinition<?> type = null;\r
\r
- SchemaPath path = createSchemaPath(actualPath, namespace, revision);\r
+ SchemaPath path = createSchemaPath(actualPath, namespace, revision, typeName);\r
if (typeName.startsWith("int")) {\r
- if (typeName.equals("int8")) {\r
+ if ("int8".equals(typeName)) {\r
type = new Int8(path);\r
- } else if (typeName.equals("int16")) {\r
+ } else if ("int16".equals(typeName)) {\r
type = new Int16(path);\r
- } else if (typeName.equals("int32")) {\r
+ } else if ("int32".equals(typeName)) {\r
type = new Int32(path);\r
- } else if (typeName.equals("int64")) {\r
+ } else if ("int64".equals(typeName)) {\r
type = new Int64(path);\r
}\r
} else if (typeName.startsWith("uint")) {\r
- if (typeName.equals("uint8")) {\r
+ if ("uint8".equals(typeName)) {\r
type = new Uint8(path);\r
- } else if (typeName.equals("uint16")) {\r
+ } else if ("uint16".equals(typeName)) {\r
type = new Uint16(path);\r
- } else if (typeName.equals("uint32")) {\r
+ } else if ("uint32".equals(typeName)) {\r
type = new Uint32(path);\r
- } else if (typeName.equals("uint64")) {\r
+ } else if ("uint64".equals(typeName)) {\r
type = new Uint64(path);\r
}\r
} else if ("string".equals(typeName)) {\r
return type;\r
}\r
\r
- private static SchemaPath createSchemaPath(List<String> actualPath, URI namespace, Date revision) {\r
+ private static SchemaPath createSchemaPath(List<String> actualPath, URI namespace, Date revision, String typeName) {\r
+ List<String> correctPath = new ArrayList<String>(actualPath);\r
+ // remove module name\r
+ correctPath.remove(0);\r
+\r
List<QName> path = new ArrayList<QName>();\r
- for(String element : actualPath) {\r
+ for(String element : correctPath) {\r
path.add(new QName(namespace, revision, element));\r
}\r
+ // add type qname\r
+ QName typeQName = new QName(BaseTypes.BaseTypesNamespace, typeName);\r
+ path.add(typeQName);\r
return new SchemaPath(path, true);\r
}\r
\r