Splitted Integer Type into Unsigned and Signed Integer Type.
Updated documentation.
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.util;\r
-\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
-import org.opendaylight.controller.model.api.type.RangeConstraint;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
-\r
-public abstract class AbstractInteger implements IntegerTypeDefinition {\r
-\r
- private final QName name;\r
- private final SchemaPath path;\r
-\r
- private final String description;\r
- private final String reference;\r
-\r
- private String units = "";\r
- private final List<RangeConstraint> rangeStatements;\r
-\r
- public AbstractInteger(final QName name, final String description,\r
- final String reference) {\r
- super();\r
- this.name = name;\r
- this.description = description;\r
- this.reference = reference;\r
- this.path = BaseTypes.schemaPath(name);\r
-\r
- final List<? extends RangeConstraint> emptyContstraints = Collections\r
- .emptyList();\r
- this.rangeStatements = Collections.unmodifiableList(emptyContstraints);\r
- }\r
-\r
- public AbstractInteger(QName name, String description, String reference,\r
- List<RangeConstraint> rangeStatements) {\r
- super();\r
- this.name = name;\r
- this.description = description;\r
- this.reference = reference;\r
- this.rangeStatements = rangeStatements;\r
- this.path = BaseTypes.schemaPath(name);\r
- }\r
-\r
- public AbstractInteger(QName name, String description, String reference,\r
- String units) {\r
- super();\r
- this.name = name;\r
- this.description = description;\r
- this.reference = reference;\r
- this.units = units;\r
- this.path = BaseTypes.schemaPath(name);\r
-\r
- final List<? extends RangeConstraint> emptyContstraints = Collections\r
- .emptyList();\r
- this.rangeStatements = Collections.unmodifiableList(emptyContstraints);\r
- }\r
-\r
- public AbstractInteger(QName name, String description, String reference,\r
- String units, List<RangeConstraint> rangeStatements) {\r
- super();\r
- this.name = name;\r
- this.description = description;\r
- this.reference = reference;\r
- this.units = units;\r
- this.rangeStatements = rangeStatements;\r
- this.path = BaseTypes.schemaPath(name);\r
- }\r
-\r
- @Override\r
- public String getUnits() {\r
- return units;\r
- }\r
-\r
- @Override\r
- public QName getQName() {\r
- return name;\r
- }\r
-\r
- @Override\r
- public SchemaPath getPath() {\r
- return path;\r
- }\r
-\r
- @Override\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- @Override\r
- public String getReference() {\r
- return reference;\r
- }\r
-\r
- @Override\r
- public Status getStatus() {\r
- return Status.CURRENT;\r
- }\r
-\r
- @Override\r
- public List<RangeConstraint> getRangeStatements() {\r
- return rangeStatements;\r
- }\r
-\r
- @Override\r
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
- return Collections.emptyList();\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- final int prime = 31;\r
- int result = 1;\r
- result = prime * result\r
- + ((description == null) ? 0 : description.hashCode());\r
- result = prime * result + ((name == null) ? 0 : name.hashCode());\r
- result = prime * result + ((path == null) ? 0 : path.hashCode());\r
- result = prime * result\r
- + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());\r
- result = prime * result\r
- + ((reference == null) ? 0 : reference.hashCode());\r
- result = prime * result + ((units == null) ? 0 : units.hashCode());\r
- return result;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj) {\r
- return true;\r
- }\r
- if (obj == null) {\r
- return false;\r
- }\r
- if (getClass() != obj.getClass()) {\r
- return false;\r
- }\r
- AbstractInteger other = (AbstractInteger) obj;\r
- if (description == null) {\r
- if (other.description != null) {\r
- return false;\r
- }\r
- } else if (!description.equals(other.description)) {\r
- return false;\r
- }\r
- if (name == null) {\r
- if (other.name != null) {\r
- return false;\r
- }\r
- } else if (!name.equals(other.name)) {\r
- return false;\r
- }\r
- if (path == null) {\r
- if (other.path != null) {\r
- return false;\r
- }\r
- } else if (!path.equals(other.path)) {\r
- return false;\r
- }\r
- if (rangeStatements == null) {\r
- if (other.rangeStatements != null) {\r
- return false;\r
- }\r
- } else if (!rangeStatements.equals(other.rangeStatements)) {\r
- return false;\r
- }\r
- if (reference == null) {\r
- if (other.reference != null) {\r
- return false;\r
- }\r
- } else if (!reference.equals(other.reference)) {\r
- return false;\r
- }\r
- if (units == null) {\r
- if (other.units != null) {\r
- return false;\r
- }\r
- } else if (!units.equals(other.units)) {\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- StringBuilder builder = new StringBuilder();\r
- builder.append("AbstractInteger [name=");\r
- builder.append(name);\r
- builder.append(", path=");\r
- builder.append(path);\r
- builder.append(", description=");\r
- builder.append(description);\r
- builder.append(", reference=");\r
- builder.append(reference);\r
- builder.append(", units=");\r
- builder.append(units);\r
- builder.append(", rangeStatements=");\r
- builder.append(rangeStatements);\r
- builder.append("]");\r
- return builder.toString();\r
- }\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.model.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.controller.model.api.type.RangeConstraint;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+
+/**
+ * The Abstract Integer class defines implementation of IntegerTypeDefinition
+ * interface which represents SIGNED Integer values defined in Yang language. <br>
+ * The integer built-in types in Yang are int8, int16, int32, int64. They
+ * represent signed integers of different sizes:
+ *
+ * <ul>
+ * <li>int8 - represents integer values between -128 and 127, inclusively.</li>
+ * <li>int16 - represents integer values between -32768 and 32767, inclusively.</li>
+ * <li>int32 - represents integer values between -2147483648 and 2147483647,
+ * inclusively.</li>
+ * <li>int64 - represents integer values between -9223372036854775808 and
+ * 9223372036854775807, inclusively.</li>
+ * </ul>
+ *
+ */
+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;
+
+ /**
+ * @param name
+ * @param description
+ * @param minRange
+ * @param maxRange
+ * @param units
+ */
+ public 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
+ * @param rangeStatements
+ * @param units
+ */
+ public AbstractSignedInteger(final QName name, final String description,
+ final List<RangeConstraint> rangeStatements, final String units) {
+ this.name = name;
+ this.description = description;
+ this.path = BaseTypes.schemaPath(name);
+ this.units = units;
+ this.rangeStatements = rangeStatements;
+ }
+
+ @Override
+ public String getUnits() {
+ return units;
+ }
+
+ @Override
+ public QName getQName() {
+ return name;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getReference() {
+ return reference;
+ }
+
+ @Override
+ public Status getStatus() {
+ return Status.CURRENT;
+ }
+
+ @Override
+ public List<RangeConstraint> getRangeStatements() {
+ return rangeStatements;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ result = prime * result
+ + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
+ result = prime * result
+ + ((reference == null) ? 0 : reference.hashCode());
+ result = prime * result + ((units == null) ? 0 : units.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AbstractSignedInteger other = (AbstractSignedInteger) obj;
+ if (description == null) {
+ if (other.description != null) {
+ return false;
+ }
+ } else if (!description.equals(other.description)) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ if (rangeStatements == null) {
+ if (other.rangeStatements != null) {
+ return false;
+ }
+ } else if (!rangeStatements.equals(other.rangeStatements)) {
+ return false;
+ }
+ if (reference == null) {
+ if (other.reference != null) {
+ return false;
+ }
+ } else if (!reference.equals(other.reference)) {
+ return false;
+ }
+ if (units == null) {
+ if (other.units != null) {
+ return false;
+ }
+ } else if (!units.equals(other.units)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("AbstractInteger [name=");
+ builder.append(name);
+ builder.append(", path=");
+ builder.append(path);
+ builder.append(", description=");
+ builder.append(description);
+ builder.append(", reference=");
+ builder.append(reference);
+ builder.append(", units=");
+ builder.append(units);
+ builder.append(", rangeStatements=");
+ builder.append(rangeStatements);
+ builder.append("]");
+ return builder.toString();
+ }
+}
--- /dev/null
+/**
+ *
+ */
+package org.opendaylight.controller.model.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.model.api.type.RangeConstraint;
+import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+
+/**
+ * The Abstract Integer class defines implementation of IntegerTypeDefinition
+ * interface which represents UNSIGNED Integer values defined in Yang language. <br>
+ * The integer built-in types in Yang are uint8, uint16, uint32, and uint64. They
+ * represent unsigned integers of different sizes:
+ *
+ * <ul>
+ * <li>uint8 - represents integer values between 0 and 255, inclusively.</li>
+ * <li>uint16 - represents integer values between 0 and 65535, inclusively.</li>
+ * <li>uint32 - represents integer values between 0 and 4294967295,
+ inclusively.</li>
+ * <li>uint64 - represents integer values between 0 and 18446744073709551615,
+ inclusively.</li>
+ * </ul>
+ *
+ */
+public abstract class AbstractUnsignedInteger implements
+ UnsignedIntegerTypeDefinition {
+ 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;
+
+ /**
+ * @param name
+ * @param description
+ * @param minRange
+ * @param maxRange
+ * @param units
+ */
+ public 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 name
+ * @param description
+ * @param rangeStatements
+ * @param units
+ */
+ public AbstractUnsignedInteger(final QName name, final String description,
+ final List<RangeConstraint> rangeStatements, final String units) {
+ this.name = name;
+ this.description = description;
+ this.path = BaseTypes.schemaPath(name);
+ this.units = units;
+ this.rangeStatements = rangeStatements;
+ }
+
+ @Override
+ public String getUnits() {
+ return units;
+ }
+
+ @Override
+ public QName getQName() {
+ return name;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getReference() {
+ return reference;
+ }
+
+ @Override
+ public Status getStatus() {
+ return Status.CURRENT;
+ }
+
+ @Override
+ public List<RangeConstraint> getRangeStatements() {
+ return rangeStatements;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ result = prime * result
+ + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
+ result = prime * result
+ + ((reference == null) ? 0 : reference.hashCode());
+ result = prime * result + ((units == null) ? 0 : units.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AbstractUnsignedInteger other = (AbstractUnsignedInteger) obj;
+ if (description == null) {
+ if (other.description != null) {
+ return false;
+ }
+ } else if (!description.equals(other.description)) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ if (rangeStatements == null) {
+ if (other.rangeStatements != null) {
+ return false;
+ }
+ } else if (!rangeStatements.equals(other.rangeStatements)) {
+ return false;
+ }
+ if (reference == null) {
+ if (other.reference != null) {
+ return false;
+ }
+ } else if (!reference.equals(other.reference)) {
+ return false;
+ }
+ if (units == null) {
+ if (other.units != null) {
+ return false;
+ }
+ } else if (!units.equals(other.units)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("AbstractInteger [name=");
+ builder.append(name);
+ builder.append(", path=");
+ builder.append(path);
+ builder.append(", description=");
+ builder.append(description);
+ builder.append(", reference=");
+ builder.append(reference);
+ builder.append(", units=");
+ builder.append(units);
+ builder.append(", rangeStatements=");
+ builder.append(rangeStatements);
+ builder.append("]");
+ return builder.toString();
+ }
+}
return new LengthConstraintImpl(min, max, description, reference);\r
}\r
\r
- public static RangeConstraint rangeConstraint(final long min,\r
- final long max, final String description, final String reference) {\r
+ public static RangeConstraint rangeConstraint(final Number min,\r
+ final Number max, final String description, final String reference) {\r
return new RangeConstraintImpl(min, max, description, reference);\r
}\r
\r
}\r
\r
private final static class RangeConstraintImpl implements RangeConstraint {\r
- private final Long min;\r
- private final Long max;\r
+ private final Number min;\r
+ private final Number max;\r
\r
private final String description;\r
private final String reference;\r
private final String errorAppTag;\r
private final String errorMessage;\r
\r
- public RangeConstraintImpl(Long min, Long max, String description,\r
+ public RangeConstraintImpl(Number min, Number max, String description,\r
String reference) {\r
super();\r
this.min = min;\r
}\r
\r
@Override\r
- public Long getMin() {\r
+ public Number getMin() {\r
return min;\r
}\r
\r
@Override\r
- public Long getMax() {\r
+ public Number getMax() {\r
return max;\r
}\r
\r
\r
public final class BaseTypes {\r
\r
- private BaseTypes() {\r
- }\r
+ private BaseTypes() {}\r
\r
public static final URI BaseTypesNamespace = URI\r
.create("urn:ietf:params:xml:ns:yang:1");\r
\r
+ /**\r
+ * Construct QName for Built-in base Yang type. The namespace for\r
+ * built-in base yang types is defined as: urn:ietf:params:xml:ns:yang:1\r
+ * \r
+ * @param typeName yang type name\r
+ * @return built-in base yang type QName.\r
+ */\r
public static final QName constructQName(final String typeName) {\r
return new QName(BaseTypesNamespace, typeName);\r
}\r
\r
+ /**\r
+ * Creates Schema Path from Qname.\r
+ * \r
+ * @param typeName yang type QName\r
+ * @return Schema Path from Qname.\r
+ */\r
public static final SchemaPath schemaPath(final QName typeName) {\r
final List<QName> pathList = new ArrayList<QName>();\r
pathList.add(typeName);\r
*/\r
package org.opendaylight.controller.model.util;\r
\r
+import java.util.ArrayList;\r
import java.util.Collections;\r
import java.util.List;\r
\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of Binary Type Definition interface.\r
+ * \r
+ * @see BinaryTypeDefinition\r
+ */\r
public class BinaryType implements BinaryTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("binary");\r
private final SchemaPath path = BaseTypes.schemaPath(name);\r
- private final String description = "";\r
- private final String reference = "";\r
+ private final String description = "The binary built-in type represents any binary data, i.e., a sequence of octets.";\r
+ private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.8";\r
\r
private List<Byte> bytes;\r
private final List<LengthConstraint> lengthConstraints;\r
private String units = "";\r
\r
+ /**\r
+ * \r
+ */\r
public BinaryType() {\r
super();\r
-\r
- lengthConstraints = Collections.emptyList();\r
+ \r
+ final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();\r
+ constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));\r
+ lengthConstraints = Collections.unmodifiableList(constraints);\r
bytes = Collections.emptyList();\r
- bytes = Collections.unmodifiableList(bytes);\r
}\r
\r
+ /**\r
+ * \r
+ * \r
+ * @param bytes\r
+ * @param lengthConstraints\r
+ * @param units\r
+ */\r
public BinaryType(final List<Byte> bytes,\r
final List<LengthConstraint> lengthConstraints, final String units) {\r
super();\r
- this.bytes = bytes;\r
- this.lengthConstraints = lengthConstraints;\r
+ \r
+ if ((lengthConstraints == null) || (lengthConstraints.isEmpty())) {\r
+ final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();\r
+ constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));\r
+ this.lengthConstraints = Collections.unmodifiableList(constraints);\r
+ } else {\r
+ this.lengthConstraints = Collections.unmodifiableList(lengthConstraints);\r
+ }\r
+ \r
+ this.bytes = Collections.unmodifiableList(bytes);\r
this.units = units;\r
}\r
\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+\r
+/**\r
+ * The <code>default</code> implementation of Bits Type Definition interface.\r
+ * \r
+ * @see BitsTypeDefinition\r
+ */\r
public class BitsType implements BitsTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("bits");\r
private final SchemaPath path = BaseTypes.schemaPath(name);\r
- private final String description = "";\r
- private final String reference = "";\r
+ private final String description = "The bits built-in type represents a bit set. " +\r
+ "That is, a bits value is a set of flags identified by small integer position " +\r
+ "numbers starting at 0. Each bit number has an assigned name.";\r
+ \r
+ private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";\r
\r
private final List<Bit> bits;\r
private String units = "";\r
/**\r
* Default constructor. <br>\r
* Instantiates Bits type as empty bits list.\r
- * \r
*/\r
public BitsType() {\r
super();\r
}\r
\r
/**\r
- * Overloaded constructor with explicit definition of bits assigned to\r
+ * Constructor with explicit definition of bits assigned to\r
* BitsType.\r
* \r
* @param bits\r
this.units = "";\r
}\r
\r
+ /**\r
+ * Constructor with explicit definition of bits assigned to\r
+ * BitsType and Units.\r
+ * <br>\r
+ * The default value of Bits Type is List of bits.\r
+ * \r
+ * @param bits The bits assigned for Bits Type\r
+ * @param units units for bits type\r
+ */\r
public BitsType(List<Bit> bits, String units) {\r
super();\r
this.bits = Collections.unmodifiableList(bits);\r
- ;\r
this.units = units;\r
}\r
\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of Boolean Type Definition interface.\r
+ * \r
+ * @see BooleanTypeDefinition\r
+ */\r
public class BooleanType implements BooleanTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("boolean");\r
private final SchemaPath path = BaseTypes.schemaPath(name);\r
- private final String description = "";\r
- private final String reference = "";\r
+ private final String description = "The boolean built-in type represents a boolean value.";\r
+ private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.5";\r
\r
private final Boolean defaultValue;\r
private String units = "";\r
}\r
\r
/**\r
+ * Boolean Type constructor.\r
* \r
- * \r
- * @param defaultValue\r
+ * @param defaultValue Default Value\r
*/\r
public BooleanType(final Boolean defaultValue) {\r
super();\r
}\r
\r
/**\r
+ * Boolean Type constructor.\r
* \r
- * \r
- * @param defaultValue\r
- * @param units\r
+ * @param defaultValue Default Value\r
+ * @param units Units\r
*/\r
public BooleanType(final Boolean defaultValue, final String units) {\r
super();\r
/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
package org.opendaylight.controller.model.util;\r
\r
import java.math.BigDecimal;\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of Decimal Type Definition interface.\r
+ * \r
+ * \r
+ * @see DecimalTypeDefinition\r
+ */\r
public class Decimal64 implements DecimalTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("decimal64");\r
private BigDecimal defaultValue = null;\r
\r
private final String description = "The decimal64 type represents a subset of the real numbers, which can "\r
- + "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can "\r
+ + "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can "\r
+ "be obtained by multiplying a 64-bit signed integer by a negative power of ten, i.e., expressible as "\r
+ "'i x 10^-n' where i is an integer64 and n is an integer between 1 and 18, inclusively.";\r
\r
private final List<RangeConstraint> rangeStatements;\r
private final Integer fractionDigits;\r
\r
+ /**\r
+ * Default Decimal64 Type Constructor. <br>\r
+ * <br>\r
+ * The initial range statements are set to Decimal64\r
+ * <code>min=-922337203685477580.8</code> and\r
+ * <code>max=922337203685477580.7</code> <br>\r
+ * The fractions digits MUST be defined as integer between 1 and 18\r
+ * inclusively as defined interface {@link DecimalTypeDefinition} <br>\r
+ * If the fraction digits are not defined inner the definition boundaries\r
+ * the constructor will throw {@link IllegalArgumentException}\r
+ * \r
+ * @param fractionDigits\r
+ * integer between 1 and 18 inclusively\r
+ * \r
+ * @see DecimalTypeDefinition\r
+ * @exception IllegalArgumentException\r
+ */\r
public Decimal64(final Integer fractionDigits) {\r
super();\r
+ if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {\r
+ throw new IllegalArgumentException(\r
+ "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");\r
+ }\r
this.fractionDigits = fractionDigits;\r
- rangeStatements = new ArrayList<RangeConstraint>();\r
+ rangeStatements = defaultRangeStatements();\r
this.path = BaseTypes.schemaPath(name);\r
}\r
\r
+ /**\r
+ * Decimal64 Type Constructor. <br>\r
+ * \r
+ * If parameter <code>Range Statements</code> is <code>null</code> or\r
+ * defined as <code>empty List</code> the constructor automatically assigns\r
+ * the boundaries as min and max value defined for Decimal64 in <a\r
+ * href="https://tools.ietf.org/html/rfc6020#section-9.3">[RFC-6020] The\r
+ * decimal64 Built-In Type</a> <br>\r
+ * <br>\r
+ * The fractions digits MUST be defined as integer between 1 and 18\r
+ * inclusively as defined interface {@link DecimalTypeDefinition} <br>\r
+ * If the fraction digits are not defined inner the definition boundaries\r
+ * the constructor will throw {@link IllegalArgumentException}\r
+ * \r
+ * @param rangeStatements\r
+ * Range Constraint Statements\r
+ * @param fractionDigits\r
+ * integer between 1 and 18 inclusively\r
+ * @exception IllegalArgumentException\r
+ */\r
public Decimal64(final List<RangeConstraint> rangeStatements,\r
Integer fractionDigits) {\r
super();\r
- this.rangeStatements = rangeStatements;\r
+ if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {\r
+ throw new IllegalArgumentException(\r
+ "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");\r
+ }\r
+ if (rangeStatements == null || rangeStatements.isEmpty()) {\r
+ this.rangeStatements = defaultRangeStatements();\r
+ } else {\r
+ this.rangeStatements = Collections.unmodifiableList(rangeStatements);\r
+ }\r
this.fractionDigits = fractionDigits;\r
this.path = BaseTypes.schemaPath(name);\r
}\r
\r
+ /**\r
+ * Decimal64 Type Constructor. <br>\r
+ * If parameter <code>Range Statements</code> is <code>null</code> or\r
+ * defined as <code>empty List</code> the constructor automatically assigns\r
+ * the boundaries as min and max value defined for Decimal64 in <a\r
+ * href="https://tools.ietf.org/html/rfc6020#section-9.3">[RFC-6020] The\r
+ * decimal64 Built-In Type</a> <br>\r
+ * <br>\r
+ * The fractions digits MUST be defined as integer between 1 and 18\r
+ * inclusively as defined interface {@link DecimalTypeDefinition} <br>\r
+ * If the fraction digits are not defined inner the definition boundaries\r
+ * the constructor will throw {@link IllegalArgumentException}\r
+ * \r
+ * @param units\r
+ * units associated with the type\r
+ * @param defaultValue\r
+ * Default Value for type\r
+ * @param rangeStatements\r
+ * Range Constraint Statements\r
+ * @param fractionDigits\r
+ * integer between 1 and 18 inclusively\r
+ * \r
+ * @exception IllegalArgumentException\r
+ */\r
public Decimal64(final String units, final BigDecimal defaultValue,\r
final List<RangeConstraint> rangeStatements,\r
final Integer fractionDigits) {\r
super();\r
+ if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {\r
+ throw new IllegalArgumentException(\r
+ "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");\r
+ }\r
+\r
+ if (rangeStatements == null || rangeStatements.isEmpty()) {\r
+ this.rangeStatements = defaultRangeStatements();\r
+ \r
+ } else {\r
+ this.rangeStatements = Collections.unmodifiableList(rangeStatements);\r
+ }\r
this.units = units;\r
this.defaultValue = defaultValue;\r
- this.rangeStatements = rangeStatements;\r
this.fractionDigits = fractionDigits;\r
this.path = BaseTypes.schemaPath(name);\r
}\r
\r
+ /**\r
+ * Returns unmodifiable List with default definition of Range Statements.\r
+ * \r
+ * @return unmodifiable List with default definition of Range Statements.\r
+ */\r
+ private List<RangeConstraint> defaultRangeStatements() {\r
+ final List<RangeConstraint> rangeStatements = new ArrayList<RangeConstraint>();\r
+ final BigDecimal min = new BigDecimal("-922337203685477580.8");\r
+ final BigDecimal max = new BigDecimal("922337203685477580.7");\r
+ final String rangeDescription = "Integer values between " + min\r
+ + " and " + max + ", inclusively.";\r
+ rangeStatements.add(BaseConstraints.rangeConstraint(min, max,\r
+ rangeDescription,\r
+ "https://tools.ietf.org/html/rfc6020#section-9.2.4"));\r
+ return Collections.unmodifiableList(rangeStatements);\r
+ }\r
+\r
@Override\r
public DecimalTypeDefinition getBaseType() {\r
return this;\r
return fractionDigits;\r
}\r
\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+ result = prime * result + ((path == null) ? 0 : path.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (getClass() != obj.getClass()) {\r
+ return false;\r
+ }\r
+ Decimal64 other = (Decimal64) obj;\r
+ if (name == null) {\r
+ if (other.name != null) {\r
+ return false;\r
+ }\r
+ } else if (!name.equals(other.name)) {\r
+ return false;\r
+ }\r
+ if (path == null) {\r
+ if (other.path != null) {\r
+ return false;\r
+ }\r
+ } else if (!path.equals(other.path)) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
@Override\r
public String toString() {\r
return Decimal64.class.getSimpleName() + "[qname=" + name\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of Enumertaion Type Definition interface.\r
+ * \r
+ * @see EnumTypeDefinition\r
+ */\r
public class EnumerationType implements EnumTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("enumeration");\r
\r
public EnumerationType(final List<EnumPair> enums) {\r
super();\r
- this.enums = enums;\r
-\r
+ this.enums = Collections.unmodifiableList(enums);\r
defaultEnum = Collections.emptyList();\r
}\r
\r
public EnumerationType(final List<EnumPair> defaultEnum,\r
final List<EnumPair> enums, final String units) {\r
super();\r
- this.defaultEnum = defaultEnum;\r
- this.enums = enums;\r
+ this.defaultEnum = Collections.unmodifiableList(defaultEnum);\r
+ this.enums = Collections.unmodifiableList(enums);\r
this.units = units;\r
}\r
\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of Identity Type Definition interface.\r
+ * \r
+ * @see IdentityTypeDefinition\r
+ */\r
public class IdentityType implements IdentityTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("identity");\r
private final SchemaPath path = BaseTypes.schemaPath(name);\r
- private final String description = "";\r
- private final String reference = "";\r
+ private final String description = "The 'identity' statement is used to define a new " +\r
+ "globally unique, abstract, and untyped identity.";\r
+ private final String reference = "https://tools.ietf.org/html/rfc6020#section-7.16";\r
\r
private String units = "";\r
private final QName identityName;\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of Identityref Type Definition interface.\r
+ *\r
+ * @see IdentityrefTypeDefinition\r
+ */\r
public class Identityref implements IdentityrefTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("identityref");\r
private final SchemaPath path = BaseTypes.schemaPath(name);\r
- private final String description = "";\r
- private final String reference = "";\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
\r
private final IdentityTypeDefinition identity;\r
private final RevisionAwareXPath xpath;\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of Instance Identifier Type Definition interface.\r
+ *\r
+ * @see InstanceIdentifierTypeDefinition\r
+ */\r
public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {\r
\r
private static final QName name = BaseTypes\r
.constructQName("instance-identifier");\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = "The instance-identifier built-in type is used to " +\r
+ "uniquely identify a particular instance node in the data tree.";\r
+ private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.13";\r
\r
private final transient SchemaPath path = BaseTypes.schemaPath(name);\r
private final RevisionAwareXPath xpath;\r
/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
package org.opendaylight.controller.model.util;\r
\r
import java.util.List;\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
import org.opendaylight.controller.yang.common.QName;\r
\r
-public class Int16 extends AbstractInteger {\r
+/**\r
+ * Implementation of Yang int16 built-in type. <br>\r
+ * int16 represents integer values between -32768 and 32767, inclusively. The\r
+ * Java counterpart of Yang int16 built-in type is {@link Short}.\r
+ * \r
+ * @see AbstractSignedInteger\r
+ */\r
+public class Int16 extends AbstractSignedInteger {\r
\r
private static final QName name = BaseTypes.constructQName("int16");\r
private Short defaultValue = null;\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = \r
+ "int16 represents integer values between -32768 and 32767, inclusively.";\r
\r
public Int16() {\r
- super(name, description, reference);\r
- }\r
-\r
- public Int16(final Short defaultValue) {\r
- super(name, description, reference);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Int16(final List<RangeConstraint> rangeStatements,\r
- final Short defaultValue) {\r
- super(name, description, reference, rangeStatements);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Int16(final String units, final Short defaultValue) {\r
- super(name, description, reference, units);\r
- this.defaultValue = defaultValue;\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
}\r
\r
public Int16(final List<RangeConstraint> rangeStatements,\r
final String units, final Short defaultValue) {\r
- super(name, description, reference, units, rangeStatements);\r
+ super(name, description, rangeStatements, units);\r
this.defaultValue = defaultValue;\r
}\r
\r
/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
package org.opendaylight.controller.model.util;\r
\r
import java.util.List;\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
import org.opendaylight.controller.yang.common.QName;\r
\r
-public class Int32 extends AbstractInteger {\r
+/**\r
+ * Implementation of Yang int32 built-in type. <br>\r
+ * int32 represents integer values between -2147483648 and 2147483647,\r
+ * inclusively. The Java counterpart of Yang int32 built-in type is\r
+ * {@link Integer}.\r
+ * \r
+ * @see AbstractSignedInteger\r
+ * \r
+ */\r
+public class Int32 extends AbstractSignedInteger {\r
\r
private static final QName name = BaseTypes.constructQName("int32");\r
private Integer defaultValue = null;\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = \r
+ "int32 represents integer values between -2147483648 and 2147483647, inclusively.";\r
\r
public Int32() {\r
- super(name, description, reference);\r
+ super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");\r
}\r
\r
public Int32(final Integer defaultValue) {\r
- super(name, description, reference);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Int32(final List<RangeConstraint> rangeStatements,\r
- final Integer defaultValue) {\r
- super(name, description, reference, rangeStatements);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Int32(final String units, final Integer defaultValue) {\r
- super(name, description, reference, units);\r
+ super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");\r
this.defaultValue = defaultValue;\r
}\r
\r
public Int32(final List<RangeConstraint> rangeStatements,\r
final String units, final Integer defaultValue) {\r
- super(name, description, reference, units, rangeStatements);\r
+ super(name, description, rangeStatements, units);\r
this.defaultValue = defaultValue;\r
}\r
\r
/*\r
* (non-Javadoc)\r
* \r
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
*/\r
@Override\r
public IntegerTypeDefinition getBaseType() {\r
/*\r
* (non-Javadoc)\r
* \r
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue\r
+ * ()\r
*/\r
@Override\r
public Object getDefaultValue() {\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
import org.opendaylight.controller.yang.common.QName;\r
\r
-public class Int64 extends AbstractInteger {\r
+/**\r
+ * Implementation of Yang int64 built-in type. <br>\r
+ * int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively. \r
+ * The Java counterpart of Yang int64 built-in type is\r
+ * {@link Long}.\r
+ *\r
+ */\r
+public class Int64 extends AbstractSignedInteger {\r
\r
private static final QName name = BaseTypes.constructQName("int64");\r
private Long defaultValue = null;\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = \r
+ "int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.";\r
\r
public Int64() {\r
- super(name, description, reference);\r
+ super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");\r
}\r
\r
public Int64(final Long defaultValue) {\r
- super(name, description, reference);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Int64(final List<RangeConstraint> rangeStatements,\r
- final Long defaultValue) {\r
- super(name, description, reference, rangeStatements);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Int64(final String units, final Long defaultValue) {\r
- super(name, description, reference, units);\r
+ super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");\r
this.defaultValue = defaultValue;\r
}\r
\r
public Int64(final List<RangeConstraint> rangeStatements,\r
final String units, final Long defaultValue) {\r
- super(name, description, reference, units, rangeStatements);\r
+ super(name, description, rangeStatements, units);\r
this.defaultValue = defaultValue;\r
}\r
\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
import org.opendaylight.controller.yang.common.QName;\r
\r
-public class Int8 extends AbstractInteger {\r
+/**\r
+ * Implementation of Yang int8 built-in type.\r
+ * <br>\r
+ * int8 represents integer values between -128 and 127, inclusively. The Java counterpart of \r
+ * Yang int8 built-in type is {@link Byte}.\r
+ * \r
+ * @see AbstractSignedInteger\r
+ */\r
+public class Int8 extends AbstractSignedInteger {\r
\r
private static final QName name = BaseTypes.constructQName("int8");\r
private Byte defaultValue = null;\r
- private static final String description = "";\r
- private static final String reference = "";\r
-\r
+ private static final String description = \r
+ "represents integer values between -128 and 127, inclusively.";\r
+ \r
public Int8() {\r
- super(name, description, reference);\r
+ super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");\r
}\r
\r
public Int8(final Byte defaultValue) {\r
- super(name, description, reference);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Int8(final List<RangeConstraint> rangeStatements,\r
- final Byte defaultValue) {\r
- super(name, description, reference, rangeStatements);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Int8(final String units, final Byte defaultValue) {\r
- super(name, description, reference, units);\r
+ super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");\r
this.defaultValue = defaultValue;\r
}\r
\r
public Int8(final List<RangeConstraint> rangeStatements,\r
final String units, final Byte defaultValue) {\r
- super(name, description, reference, units, rangeStatements);\r
+ super(name, description, rangeStatements, units);\r
this.defaultValue = defaultValue;\r
}\r
\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of Instance Leafref Type Definition interface.\r
+ *\r
+ * @see LeafrefTypeDefinition\r
+ */\r
public class Leafref implements LeafrefTypeDefinition {\r
private static final QName name = BaseTypes.constructQName("leafref");\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = "The leafref type is used to reference a " +\r
+ "particular leaf instance in the data tree.";\r
+ private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.9";\r
private final SchemaPath path = BaseTypes.schemaPath(name);\r
private final RevisionAwareXPath xpath;\r
private final String units = "";\r
import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
+/**
+ * The <code>default</code> implementation of Instance Rewision Aware XPath interface.
+ *
+ * @see RevisionAwareXPath
+ */
public class RevisionAwareXPathImpl implements RevisionAwareXPath {
private final String xpath;
return absolute;
}
- @Override
- public String toString() {
- return xpath;
- }
-
@Override
public int hashCode() {
final int prime = 31;
}
return false;
}
-
+
+ @Override
+ public String toString() {
+ return xpath;
+ }
}
*/\r
package org.opendaylight.controller.model.util;\r
\r
+import java.util.ArrayList;\r
import java.util.Collections;\r
import java.util.List;\r
\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
\r
+/**\r
+ * The <code>default</code> implementation of String Type Definition interface.\r
+ *\r
+ * @see StringTypeDefinition\r
+ */\r
public class StringType implements StringTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("string");;\r
private final List<PatternConstraint> patterns;\r
private String units = "";\r
\r
+ /**\r
+ * Default Constructor.\r
+ */\r
public StringType() {\r
super();\r
path = BaseTypes.schemaPath(name);\r
- this.lengthStatements = Collections.emptyList();\r
+ final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();\r
+ constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));\r
+ lengthStatements = Collections.unmodifiableList(constraints);\r
+ \r
this.patterns = Collections.emptyList();\r
}\r
\r
- public StringType(List<LengthConstraint> lengthStatements,\r
- List<PatternConstraint> patterns) {\r
+ /**\r
+ * \r
+ * \r
+ * @param lengthStatements\r
+ * @param patterns\r
+ */\r
+ public StringType(final List<LengthConstraint> lengthStatements,\r
+ final List<PatternConstraint> patterns) {\r
super();\r
path = BaseTypes.schemaPath(name);\r
this.lengthStatements = Collections.unmodifiableList(lengthStatements);\r
this.patterns = Collections.unmodifiableList(patterns);\r
}\r
\r
+ /**\r
+ * \r
+ * \r
+ * @param defaultValue\r
+ * @param lengthStatements\r
+ * @param patterns\r
+ * @param units\r
+ */\r
public StringType(final String defaultValue,\r
final List<LengthConstraint> lengthStatements,\r
final List<PatternConstraint> patterns, final String units) {\r
/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
package org.opendaylight.controller.model.util;\r
\r
import java.util.List;\r
\r
-import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition;\r
import org.opendaylight.controller.yang.common.QName;\r
\r
-public class Uint16 extends AbstractInteger {\r
+/**\r
+ * Implementation of Yang uint32 built-in type. <br>\r
+ * uint16 represents integer values between 0 and 65535, inclusively. The Java\r
+ * counterpart of Yang uint32 built-in type is {@link Integer}.\r
+ * \r
+ */\r
+public class Uint16 extends AbstractUnsignedInteger {\r
\r
private static final QName name = BaseTypes.constructQName("uint16");\r
private Integer defaultValue = null;\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";\r
\r
public Uint16() {\r
- super(name, description, reference);\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
}\r
\r
public Uint16(final Integer defaultValue) {\r
- super(name, description, reference);\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
this.defaultValue = defaultValue;\r
}\r
\r
public Uint16(final List<RangeConstraint> rangeStatements,\r
- final Integer defaultValue) {\r
- super(name, description, reference, rangeStatements);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Uint16(final String units, final Integer defaultValue) {\r
- super(name, description, reference, units);\r
+ final String units, final Integer defaultValue) {\r
+ super(name, description, rangeStatements, units);\r
this.defaultValue = defaultValue;\r
}\r
\r
/*\r
* (non-Javadoc)\r
* \r
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
*/\r
@Override\r
- public IntegerTypeDefinition getBaseType() {\r
+ public UnsignedIntegerTypeDefinition getBaseType() {\r
return this;\r
}\r
\r
/*\r
* (non-Javadoc)\r
* \r
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue\r
+ * ()\r
*/\r
@Override\r
public Object getDefaultValue() {\r
/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
package org.opendaylight.controller.model.util;\r
\r
import java.util.List;\r
\r
-import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition;\r
import org.opendaylight.controller.yang.common.QName;\r
\r
-public class Uint32 extends AbstractInteger {\r
+/**\r
+ * Implementation of Yang uint32 built-in type. <br>\r
+ * uint32 represents integer values between 0 and 4294967295, inclusively. The\r
+ * Java counterpart of Yang uint32 built-in type is {@link Long}.\r
+ * \r
+ */\r
+public class Uint32 extends AbstractUnsignedInteger {\r
\r
private static final QName name = BaseTypes.constructQName("uint32");\r
private Long defaultValue = null;\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = "uint32 represents integer values between 0 and 4294967295, inclusively.";\r
\r
public Uint32() {\r
- super(name, description, reference);\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
}\r
\r
public Uint32(final Long defaultValue) {\r
- super(name, description, reference);\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
this.defaultValue = defaultValue;\r
}\r
\r
public Uint32(final List<RangeConstraint> rangeStatements,\r
- final Long defaultValue) {\r
- super(name, description, reference, rangeStatements);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Uint32(final String units, final Long defaultValue) {\r
- super(name, description, reference, units);\r
+ final String units, final Long defaultValue) {\r
+ super(name, description, rangeStatements, units);\r
this.defaultValue = defaultValue;\r
}\r
\r
/*\r
* (non-Javadoc)\r
* \r
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
*/\r
@Override\r
- public IntegerTypeDefinition getBaseType() {\r
+ public UnsignedIntegerTypeDefinition getBaseType() {\r
return this;\r
}\r
\r
/*\r
* (non-Javadoc)\r
* \r
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue\r
+ * ()\r
*/\r
@Override\r
public Object getDefaultValue() {\r
/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
package org.opendaylight.controller.model.util;\r
\r
import java.math.BigInteger;\r
import java.util.List;\r
\r
-import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition;\r
import org.opendaylight.controller.yang.common.QName;\r
\r
-public class Uint64 extends AbstractInteger {\r
+/**\r
+ * Implementation of Yang uint64 built-in type. <br>\r
+ * uint64 represents integer values between 0 and 18446744073709551615,\r
+ * inclusively. The Java counterpart of Yang uint64 built-in type is\r
+ * {@link BigInteger}.\r
+ * \r
+ */\r
+public class Uint64 extends AbstractUnsignedInteger {\r
\r
private static final QName name = BaseTypes.constructQName("uint32");\r
private BigInteger defaultValue = null;\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = \r
+ "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";\r
\r
public Uint64() {\r
- super(name, description, reference);\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
}\r
\r
public Uint64(final BigInteger defaultValue) {\r
- super(name, description, reference);\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
this.defaultValue = defaultValue;\r
}\r
\r
public Uint64(final List<RangeConstraint> rangeStatements,\r
- final BigInteger defaultValue) {\r
- super(name, description, reference, rangeStatements);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Uint64(final String units, final BigInteger defaultValue) {\r
- super(name, description, reference, units);\r
+ final String units, final BigInteger defaultValue) {\r
+ super(name, description, rangeStatements, units);\r
this.defaultValue = defaultValue;\r
}\r
\r
/*\r
* (non-Javadoc)\r
* \r
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
*/\r
@Override\r
- public IntegerTypeDefinition getBaseType() {\r
+ public UnsignedIntegerTypeDefinition getBaseType() {\r
return this;\r
}\r
\r
/*\r
* (non-Javadoc)\r
* \r
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
+ * @see\r
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue\r
+ * ()\r
*/\r
@Override\r
public Object getDefaultValue() {\r
\r
import java.util.List;\r
\r
-import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
+import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition;\r
import org.opendaylight.controller.yang.common.QName;\r
\r
-public class Uint8 extends AbstractInteger {\r
+/**\r
+ * Implementation of Yang uint8 built-in type.\r
+ * <br>\r
+ * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of \r
+ * Yang uint8 built-in type is {@link Short}.\r
+ * \r
+ * @see AbstractUnsignedInteger\r
+ */\r
+public class Uint8 extends AbstractUnsignedInteger {\r
\r
private static final QName name = BaseTypes.constructQName("uint8");\r
private Short defaultValue = null;\r
- private static final String description = "";\r
- private static final String reference = "";\r
+ private static final String description = \r
+ "uint8 represents integer values between 0 and 255, inclusively.";\r
\r
public Uint8() {\r
- super(name, description, reference);\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
}\r
\r
public Uint8(final Short defaultValue) {\r
- super(name, description, reference);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Uint8(final List<RangeConstraint> rangeStatements,\r
- final Short defaultValue) {\r
- super(name, description, reference, rangeStatements);\r
- this.defaultValue = defaultValue;\r
- }\r
-\r
- public Uint8(final String units, final Short defaultValue) {\r
- super(name, description, reference, units);\r
+ super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
this.defaultValue = defaultValue;\r
}\r
\r
public Uint8(final List<RangeConstraint> rangeStatements,\r
final String units, final Short defaultValue) {\r
- super(name, description, reference, units, rangeStatements);\r
+ super(name, description, rangeStatements, units);\r
this.defaultValue = defaultValue;\r
}\r
\r
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
*/\r
@Override\r
- public IntegerTypeDefinition getBaseType() {\r
+ public UnsignedIntegerTypeDefinition getBaseType() {\r
return this;\r
}\r
\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
import org.opendaylight.controller.model.api.type.UnknownTypeDefinition;\r
import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
import org.opendaylight.controller.yang.model.api.SchemaPath;\r
import org.opendaylight.controller.yang.model.api.Status;\r
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
import org.opendaylight.controller.model.api.type.RangeConstraint;\r
import org.opendaylight.controller.model.api.type.StringTypeDefinition;\r
+import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition;\r
import org.opendaylight.controller.yang.common.QName;\r
import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
\r
private static final TypeDefinition<IntegerTypeDefinition> INT32_TYPE = new Int32();\r
private static final TypeDefinition<IntegerTypeDefinition> INT64_TYPE = new Int64();\r
private static final TypeDefinition<StringTypeDefinition> STRING_TYPE = new StringType();\r
- private static final TypeDefinition<IntegerTypeDefinition> UINT8_TYPE = new Uint8();\r
- private static final TypeDefinition<IntegerTypeDefinition> UINT16_TYPE = new Int16();\r
- private static final TypeDefinition<IntegerTypeDefinition> UINT32_TYPE = new Int32();\r
- private static final TypeDefinition<IntegerTypeDefinition> UINT64_TYPE = new Int64();\r
+ private static final TypeDefinition<UnsignedIntegerTypeDefinition> UINT8_TYPE = new Uint8();\r
+ private static final TypeDefinition<UnsignedIntegerTypeDefinition> UINT16_TYPE = new Uint16();\r
+ private static final TypeDefinition<UnsignedIntegerTypeDefinition> UINT32_TYPE = new Uint32();\r
+ private static final TypeDefinition<UnsignedIntegerTypeDefinition> UINT64_TYPE = new Uint64();\r
\r
static {\r
baseYangTypeMap.put("binary", BINARY);\r
return type;\r
}\r
\r
- public static TypeDefinition<IntegerTypeDefinition> javaTypeForBaseYangIntegerType(\r
- String typeName, List<RangeConstraint> ranges) {\r
+ public static TypeDefinition<IntegerTypeDefinition> javaTypeForBaseYangSignedIntegerType(\r
+ String typeName) {\r
if (typeName.equals("int8")) {\r
- return new Int8(ranges, null);\r
+ return new Int8();\r
} else if (typeName.equals("int16")) {\r
- return new Int16(ranges, null);\r
+ return new Int16();\r
} else if (typeName.equals("int32")) {\r
- return new Int32(ranges, null);\r
+ return new Int32();\r
} else if (typeName.equals("int64")) {\r
- return new Int64(ranges, null);\r
- } else if (typeName.equals("uint8")) {\r
- return new Uint8(ranges, null);\r
+ return new Int64();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ public static TypeDefinition<UnsignedIntegerTypeDefinition> javaTypeForBaseYangUnsignedIntegerType(\r
+ final String typeName) {\r
+ if (typeName.equals("uint8")) {\r
+ return new Uint8();\r
} else if (typeName.equals("uint16")) {\r
- return new Uint16(ranges, null);\r
+ return new Uint16();\r
} else if (typeName.equals("uint32")) {\r
- return new Uint32(ranges, null);\r
+ return new Uint32();\r
} else if (typeName.equals("uint64")) {\r
- return new Uint64(ranges, null);\r
+ return new Uint64();\r
}\r
return null;\r
}\r