From: Lukas Sedlak Date: Thu, 28 Mar 2013 12:58:52 +0000 (+0100) Subject: Updated YANG Type definitions and documentation in YANG Model Utils. X-Git-Tag: releasepom-0.1.0~622 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=0fa3b1c50cf625fc37dd57350d3fa7db1b1b8eac Updated YANG Type definitions and documentation in YANG Model Utils. Splitted Integer Type into Unsigned and Signed Integer Type. Updated documentation. Signed-off-by: Tony Tkacik --- diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractInteger.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractSignedInteger.java similarity index 71% rename from opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractInteger.java rename to opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractSignedInteger.java index 33cb2b0268..ec5a5dd4c0 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractInteger.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractSignedInteger.java @@ -1,210 +1,213 @@ -/* - * 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.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; - -public abstract class AbstractInteger implements IntegerTypeDefinition { - - private final QName name; - private final SchemaPath path; - - private final String description; - private final String reference; - - private String units = ""; - private final List rangeStatements; - - public AbstractInteger(final QName name, final String description, - final String reference) { - super(); - this.name = name; - this.description = description; - this.reference = reference; - this.path = BaseTypes.schemaPath(name); - - final List emptyContstraints = Collections - .emptyList(); - this.rangeStatements = Collections.unmodifiableList(emptyContstraints); - } - - public AbstractInteger(QName name, String description, String reference, - List rangeStatements) { - super(); - this.name = name; - this.description = description; - this.reference = reference; - this.rangeStatements = rangeStatements; - this.path = BaseTypes.schemaPath(name); - } - - public AbstractInteger(QName name, String description, String reference, - String units) { - super(); - this.name = name; - this.description = description; - this.reference = reference; - this.units = units; - this.path = BaseTypes.schemaPath(name); - - final List emptyContstraints = Collections - .emptyList(); - this.rangeStatements = Collections.unmodifiableList(emptyContstraints); - } - - public AbstractInteger(QName name, String description, String reference, - String units, List rangeStatements) { - super(); - this.name = name; - this.description = description; - this.reference = reference; - this.units = units; - this.rangeStatements = rangeStatements; - this.path = BaseTypes.schemaPath(name); - } - - @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 getRangeStatements() { - return rangeStatements; - } - - @Override - public List 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; - } - AbstractInteger other = (AbstractInteger) 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(); - } -} +/* + * 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.
+ * The integer built-in types in Yang are int8, int16, int32, int64. They + * represent signed integers of different sizes: + * + *
    + *
  • int8 - represents integer values between -128 and 127, inclusively.
  • + *
  • int16 - represents integer values between -32768 and 32767, inclusively.
  • + *
  • int32 - represents integer values between -2147483648 and 2147483647, + * inclusively.
  • + *
  • int64 - represents integer values between -9223372036854775808 and + * 9223372036854775807, inclusively.
  • + *
+ * + */ +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 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(); + 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 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 getRangeStatements() { + return rangeStatements; + } + + @Override + public List 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(); + } +} diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractUnsignedInteger.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractUnsignedInteger.java new file mode 100644 index 0000000000..86c543e641 --- /dev/null +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractUnsignedInteger.java @@ -0,0 +1,209 @@ +/** + * + */ +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.
+ * The integer built-in types in Yang are uint8, uint16, uint32, and uint64. They + * represent unsigned integers of different sizes: + * + *
    + *
  • uint8 - represents integer values between 0 and 255, inclusively.
  • + *
  • uint16 - represents integer values between 0 and 65535, inclusively.
  • + *
  • uint32 - represents integer values between 0 and 4294967295, + inclusively.
  • + *
  • uint64 - represents integer values between 0 and 18446744073709551615, + inclusively.
  • + *
+ * + */ +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 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(); + 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 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 getRangeStatements() { + return rangeStatements; + } + + @Override + public List 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(); + } +} diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BaseConstraints.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BaseConstraints.java index 881a3e8640..f78f8589a1 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BaseConstraints.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BaseConstraints.java @@ -21,8 +21,8 @@ public final class BaseConstraints { return new LengthConstraintImpl(min, max, description, reference); } - public static RangeConstraint rangeConstraint(final long min, - final long max, final String description, final String reference) { + public static RangeConstraint rangeConstraint(final Number min, + final Number max, final String description, final String reference) { return new RangeConstraintImpl(min, max, description, reference); } @@ -172,8 +172,8 @@ public final class BaseConstraints { } private final static class RangeConstraintImpl implements RangeConstraint { - private final Long min; - private final Long max; + private final Number min; + private final Number max; private final String description; private final String reference; @@ -181,7 +181,7 @@ public final class BaseConstraints { private final String errorAppTag; private final String errorMessage; - public RangeConstraintImpl(Long min, Long max, String description, + public RangeConstraintImpl(Number min, Number max, String description, String reference) { super(); this.min = min; @@ -215,12 +215,12 @@ public final class BaseConstraints { } @Override - public Long getMin() { + public Number getMin() { return min; } @Override - public Long getMax() { + public Number getMax() { return max; } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BaseTypes.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BaseTypes.java index e02173c5de..6a25bc815c 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BaseTypes.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BaseTypes.java @@ -16,16 +16,28 @@ import org.opendaylight.controller.yang.model.api.SchemaPath; public final class BaseTypes { - private BaseTypes() { - } + private BaseTypes() {} public static final URI BaseTypesNamespace = URI .create("urn:ietf:params:xml:ns:yang:1"); + /** + * Construct QName for Built-in base Yang type. The namespace for + * built-in base yang types is defined as: urn:ietf:params:xml:ns:yang:1 + * + * @param typeName yang type name + * @return built-in base yang type QName. + */ public static final QName constructQName(final String typeName) { return new QName(BaseTypesNamespace, typeName); } + /** + * Creates Schema Path from Qname. + * + * @param typeName yang type QName + * @return Schema Path from Qname. + */ public static final SchemaPath schemaPath(final QName typeName) { final List pathList = new ArrayList(); pathList.add(typeName); diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BinaryType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BinaryType.java index 7429c01531..2ee873b33a 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BinaryType.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BinaryType.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.model.util; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -17,30 +18,54 @@ 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 default implementation of Binary Type Definition interface. + * + * @see BinaryTypeDefinition + */ public class BinaryType implements BinaryTypeDefinition { private final QName name = BaseTypes.constructQName("binary"); private final SchemaPath path = BaseTypes.schemaPath(name); - private final String description = ""; - private final String reference = ""; + 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 List bytes; private final List lengthConstraints; private String units = ""; + /** + * + */ public BinaryType() { super(); - - lengthConstraints = Collections.emptyList(); + + final List constraints = new ArrayList(); + constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", "")); + lengthConstraints = Collections.unmodifiableList(constraints); bytes = Collections.emptyList(); - bytes = Collections.unmodifiableList(bytes); } + /** + * + * + * @param bytes + * @param lengthConstraints + * @param units + */ public BinaryType(final List bytes, final List lengthConstraints, final String units) { super(); - this.bytes = bytes; - this.lengthConstraints = lengthConstraints; + + if ((lengthConstraints == null) || (lengthConstraints.isEmpty())) { + final List constraints = new ArrayList(); + constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", "")); + this.lengthConstraints = Collections.unmodifiableList(constraints); + } else { + this.lengthConstraints = Collections.unmodifiableList(lengthConstraints); + } + + this.bytes = Collections.unmodifiableList(bytes); this.units = units; } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BitsType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BitsType.java index b783bc7730..ac7bcaab96 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BitsType.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BitsType.java @@ -16,12 +16,21 @@ 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 default implementation of Bits Type Definition interface. + * + * @see BitsTypeDefinition + */ public class BitsType implements BitsTypeDefinition { private final QName name = BaseTypes.constructQName("bits"); private final SchemaPath path = BaseTypes.schemaPath(name); - private final String description = ""; - private final String reference = ""; + private final String description = "The bits built-in type represents a bit set. " + + "That is, a bits value is a set of flags identified by small integer position " + + "numbers starting at 0. Each bit number has an assigned name."; + + private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7"; private final List bits; private String units = ""; @@ -29,7 +38,6 @@ public class BitsType implements BitsTypeDefinition { /** * Default constructor.
* Instantiates Bits type as empty bits list. - * */ public BitsType() { super(); @@ -37,7 +45,7 @@ public class BitsType implements BitsTypeDefinition { } /** - * Overloaded constructor with explicit definition of bits assigned to + * Constructor with explicit definition of bits assigned to * BitsType. * * @param bits @@ -49,10 +57,18 @@ public class BitsType implements BitsTypeDefinition { this.units = ""; } + /** + * Constructor with explicit definition of bits assigned to + * BitsType and Units. + *
+ * 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(List bits, String units) { super(); this.bits = Collections.unmodifiableList(bits); - ; this.units = units; } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BooleanType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BooleanType.java index c9d319d2c6..171612b1cd 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BooleanType.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BooleanType.java @@ -16,12 +16,17 @@ 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 default implementation of Boolean Type Definition interface. + * + * @see BooleanTypeDefinition + */ public class BooleanType implements BooleanTypeDefinition { private final QName name = BaseTypes.constructQName("boolean"); private final SchemaPath path = BaseTypes.schemaPath(name); - private final String description = ""; - private final String reference = ""; + 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 Boolean defaultValue; private String units = ""; @@ -35,9 +40,9 @@ public class BooleanType implements BooleanTypeDefinition { } /** + * Boolean Type constructor. * - * - * @param defaultValue + * @param defaultValue Default Value */ public BooleanType(final Boolean defaultValue) { super(); @@ -45,10 +50,10 @@ public class BooleanType implements BooleanTypeDefinition { } /** + * Boolean Type constructor. * - * - * @param defaultValue - * @param units + * @param defaultValue Default Value + * @param units Units */ public BooleanType(final Boolean defaultValue, final String units) { super(); diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Decimal64.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Decimal64.java index 233e4607ce..31c8c0d32d 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Decimal64.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Decimal64.java @@ -1,10 +1,10 @@ /* - * 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 - */ + * 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.math.BigDecimal; @@ -19,6 +19,12 @@ 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 default implementation of Decimal Type Definition interface. + * + * + * @see DecimalTypeDefinition + */ public class Decimal64 implements DecimalTypeDefinition { private final QName name = BaseTypes.constructQName("decimal64"); @@ -27,7 +33,7 @@ public class Decimal64 implements DecimalTypeDefinition { private 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 " + + "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can " + "be obtained by multiplying a 64-bit signed integer by a negative power of ten, i.e., expressible as " + "'i x 10^-n' where i is an integer64 and n is an integer between 1 and 18, inclusively."; @@ -36,32 +42,132 @@ public class Decimal64 implements DecimalTypeDefinition { private final List rangeStatements; private final Integer fractionDigits; + /** + * Default Decimal64 Type Constructor.
+ *
+ * The initial range statements are set to Decimal64 + * min=-922337203685477580.8 and + * max=922337203685477580.7
+ * The fractions digits MUST be defined as integer between 1 and 18 + * inclusively as defined interface {@link DecimalTypeDefinition}
+ * If the fraction digits are not defined inner the definition boundaries + * the constructor will throw {@link IllegalArgumentException} + * + * @param fractionDigits + * integer between 1 and 18 inclusively + * + * @see DecimalTypeDefinition + * @exception IllegalArgumentException + */ public Decimal64(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 = new ArrayList(); + rangeStatements = defaultRangeStatements(); this.path = BaseTypes.schemaPath(name); } + /** + * Decimal64 Type Constructor.
+ * + * If parameter Range Statements is null or + * defined as empty List the constructor automatically assigns + * the boundaries as min and max value defined for Decimal64 in [RFC-6020] The + * decimal64 Built-In Type
+ *
+ * The fractions digits MUST be defined as integer between 1 and 18 + * inclusively as defined interface {@link DecimalTypeDefinition}
+ * If the fraction digits are not defined inner the definition boundaries + * the constructor will throw {@link IllegalArgumentException} + * + * @param rangeStatements + * Range Constraint Statements + * @param fractionDigits + * integer between 1 and 18 inclusively + * @exception IllegalArgumentException + */ public Decimal64(final List rangeStatements, Integer fractionDigits) { super(); - this.rangeStatements = rangeStatements; + 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 = BaseTypes.schemaPath(name); } + /** + * Decimal64 Type Constructor.
+ * If parameter Range Statements is null or + * defined as empty List the constructor automatically assigns + * the boundaries as min and max value defined for Decimal64 in [RFC-6020] The + * decimal64 Built-In Type
+ *
+ * The fractions digits MUST be defined as integer between 1 and 18 + * inclusively as defined interface {@link DecimalTypeDefinition}
+ * If the fraction digits are not defined inner the definition boundaries + * the constructor will throw {@link IllegalArgumentException} + * + * @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 + * + * @exception IllegalArgumentException + */ public Decimal64(final String units, final BigDecimal defaultValue, final List 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.rangeStatements = rangeStatements; this.fractionDigits = fractionDigits; this.path = BaseTypes.schemaPath(name); } + /** + * Returns unmodifiable List with default definition of Range Statements. + * + * @return unmodifiable List with default definition of Range Statements. + */ + private List defaultRangeStatements() { + final List rangeStatements = new ArrayList(); + final BigDecimal min = new BigDecimal("-922337203685477580.8"); + final BigDecimal max = new BigDecimal("922337203685477580.7"); + final String rangeDescription = "Integer values between " + min + + " and " + max + ", inclusively."; + rangeStatements.add(BaseConstraints.rangeConstraint(min, max, + rangeDescription, + "https://tools.ietf.org/html/rfc6020#section-9.2.4")); + return Collections.unmodifiableList(rangeStatements); + } + @Override public DecimalTypeDefinition getBaseType() { return this; @@ -117,6 +223,44 @@ public class Decimal64 implements DecimalTypeDefinition { return fractionDigits; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((path == null) ? 0 : path.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; + } + Decimal64 other = (Decimal64) obj; + 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; + } + return true; + } + @Override public String toString() { return Decimal64.class.getSimpleName() + "[qname=" + name diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/EnumerationType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/EnumerationType.java index 34ac5374f7..66a7d30c31 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/EnumerationType.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/EnumerationType.java @@ -16,6 +16,11 @@ 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 default implementation of Enumertaion Type Definition interface. + * + * @see EnumTypeDefinition + */ public class EnumerationType implements EnumTypeDefinition { private final QName name = BaseTypes.constructQName("enumeration"); @@ -29,16 +34,15 @@ public class EnumerationType implements EnumTypeDefinition { public EnumerationType(final List enums) { super(); - this.enums = enums; - + this.enums = Collections.unmodifiableList(enums); defaultEnum = Collections.emptyList(); } public EnumerationType(final List defaultEnum, final List enums, final String units) { super(); - this.defaultEnum = defaultEnum; - this.enums = enums; + this.defaultEnum = Collections.unmodifiableList(defaultEnum); + this.enums = Collections.unmodifiableList(enums); this.units = units; } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/IdentityType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/IdentityType.java index 775d368eaf..750b11217c 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/IdentityType.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/IdentityType.java @@ -16,12 +16,18 @@ 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 default implementation of Identity Type Definition interface. + * + * @see IdentityTypeDefinition + */ public class IdentityType implements IdentityTypeDefinition { private final QName name = BaseTypes.constructQName("identity"); private final SchemaPath path = BaseTypes.schemaPath(name); - private final String description = ""; - private final String reference = ""; + private final String description = "The 'identity' statement is used to define a new " + + "globally unique, abstract, and untyped identity."; + private final String reference = "https://tools.ietf.org/html/rfc6020#section-7.16"; private String units = ""; private final QName identityName; diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Identityref.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Identityref.java index 24ab0af1ad..24c3163cc0 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Identityref.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Identityref.java @@ -18,12 +18,17 @@ 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 default implementation of Identityref Type Definition interface. + * + * @see IdentityrefTypeDefinition + */ public class Identityref implements IdentityrefTypeDefinition { private final QName name = BaseTypes.constructQName("identityref"); private final SchemaPath path = BaseTypes.schemaPath(name); - private final String description = ""; - private final String reference = ""; + private final String description = "The identityref type is used to reference an existing identity."; + private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.10"; private final IdentityTypeDefinition identity; private final RevisionAwareXPath xpath; diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/InstanceIdentifier.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/InstanceIdentifier.java index 9a238aea1f..4dd3e2164d 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/InstanceIdentifier.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/InstanceIdentifier.java @@ -17,12 +17,18 @@ 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 default implementation of Instance Identifier Type Definition interface. + * + * @see InstanceIdentifierTypeDefinition + */ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition { private static final QName name = BaseTypes .constructQName("instance-identifier"); - private static final String description = ""; - private static final String reference = ""; + private static final String description = "The instance-identifier built-in type is used to " + + "uniquely identify a particular instance node in the data tree."; + private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.13"; private final transient SchemaPath path = BaseTypes.schemaPath(name); private final RevisionAwareXPath xpath; diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int16.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int16.java index 49ac4d1649..9d23769720 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int16.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int16.java @@ -1,10 +1,10 @@ /* - * 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 - */ + * 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.List; @@ -13,36 +13,27 @@ import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; import org.opendaylight.controller.yang.common.QName; -public class Int16 extends AbstractInteger { +/** + * Implementation of Yang int16 built-in type.
+ * int16 represents integer values between -32768 and 32767, inclusively. The + * Java counterpart of Yang int16 built-in type is {@link Short}. + * + * @see AbstractSignedInteger + */ +public class Int16 extends AbstractSignedInteger { private static final QName name = BaseTypes.constructQName("int16"); private Short defaultValue = null; - private static final String description = ""; - private static final String reference = ""; + private static final String description = + "int16 represents integer values between -32768 and 32767, inclusively."; public Int16() { - super(name, description, reference); - } - - public Int16(final Short defaultValue) { - super(name, description, reference); - this.defaultValue = defaultValue; - } - - public Int16(final List rangeStatements, - final Short defaultValue) { - super(name, description, reference, rangeStatements); - this.defaultValue = defaultValue; - } - - public Int16(final String units, final Short defaultValue) { - super(name, description, reference, units); - this.defaultValue = defaultValue; + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); } public Int16(final List rangeStatements, final String units, final Short defaultValue) { - super(name, description, reference, units, rangeStatements); + super(name, description, rangeStatements, units); this.defaultValue = defaultValue; } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int32.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int32.java index 18908750c4..ee8b929942 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int32.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int32.java @@ -1,10 +1,10 @@ /* - * 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 - */ + * 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.List; @@ -13,43 +13,42 @@ import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; import org.opendaylight.controller.yang.common.QName; -public class Int32 extends AbstractInteger { +/** + * Implementation of Yang int32 built-in type.
+ * int32 represents integer values between -2147483648 and 2147483647, + * inclusively. The Java counterpart of Yang int32 built-in type is + * {@link Integer}. + * + * @see AbstractSignedInteger + * + */ +public class Int32 extends AbstractSignedInteger { private static final QName name = BaseTypes.constructQName("int32"); private Integer defaultValue = null; - private static final String description = ""; - private static final String reference = ""; + private static final String description = + "int32 represents integer values between -2147483648 and 2147483647, inclusively."; public Int32() { - super(name, description, reference); + super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, ""); } public Int32(final Integer defaultValue) { - super(name, description, reference); - this.defaultValue = defaultValue; - } - - public Int32(final List rangeStatements, - final Integer defaultValue) { - super(name, description, reference, rangeStatements); - this.defaultValue = defaultValue; - } - - public Int32(final String units, final Integer defaultValue) { - super(name, description, reference, units); + super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, ""); this.defaultValue = defaultValue; } public Int32(final List rangeStatements, final String units, final Integer defaultValue) { - super(name, description, reference, units, rangeStatements); + super(name, description, rangeStatements, units); this.defaultValue = defaultValue; } /* * (non-Javadoc) * - * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() + * @see + * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() */ @Override public IntegerTypeDefinition getBaseType() { @@ -59,7 +58,9 @@ public class Int32 extends AbstractInteger { /* * (non-Javadoc) * - * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue() + * @see + * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue + * () */ @Override public Object getDefaultValue() { diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int64.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int64.java index c03c6b7bf6..25d2b6d056 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int64.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int64.java @@ -13,36 +13,32 @@ import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; import org.opendaylight.controller.yang.common.QName; -public class Int64 extends AbstractInteger { +/** + * Implementation of Yang int64 built-in type.
+ * int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively. + * The Java counterpart of Yang int64 built-in type is + * {@link Long}. + * + */ +public class Int64 extends AbstractSignedInteger { private static final QName name = BaseTypes.constructQName("int64"); private Long defaultValue = null; - private static final String description = ""; - private static final String reference = ""; + private static final String description = + "int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively."; public Int64() { - super(name, description, reference); + super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, ""); } public Int64(final Long defaultValue) { - super(name, description, reference); - this.defaultValue = defaultValue; - } - - public Int64(final List rangeStatements, - final Long defaultValue) { - super(name, description, reference, rangeStatements); - this.defaultValue = defaultValue; - } - - public Int64(final String units, final Long defaultValue) { - super(name, description, reference, units); + super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, ""); this.defaultValue = defaultValue; } public Int64(final List rangeStatements, final String units, final Long defaultValue) { - super(name, description, reference, units, rangeStatements); + super(name, description, rangeStatements, units); this.defaultValue = defaultValue; } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int8.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int8.java index ebb5fa7c6a..53b9c19573 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int8.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Int8.java @@ -13,36 +13,33 @@ import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; import org.opendaylight.controller.yang.common.QName; -public class Int8 extends AbstractInteger { +/** + * Implementation of Yang int8 built-in type. + *
+ * int8 represents integer values between -128 and 127, inclusively. The Java counterpart of + * Yang int8 built-in type is {@link Byte}. + * + * @see AbstractSignedInteger + */ +public class Int8 extends AbstractSignedInteger { private static final QName name = BaseTypes.constructQName("int8"); private Byte defaultValue = null; - private static final String description = ""; - private static final String reference = ""; - + private static final String description = + "represents integer values between -128 and 127, inclusively."; + public Int8() { - super(name, description, reference); + super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, ""); } public Int8(final Byte defaultValue) { - super(name, description, reference); - this.defaultValue = defaultValue; - } - - public Int8(final List rangeStatements, - final Byte defaultValue) { - super(name, description, reference, rangeStatements); - this.defaultValue = defaultValue; - } - - public Int8(final String units, final Byte defaultValue) { - super(name, description, reference, units); + super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, ""); this.defaultValue = defaultValue; } public Int8(final List rangeStatements, final String units, final Byte defaultValue) { - super(name, description, reference, units, rangeStatements); + super(name, description, rangeStatements, units); this.defaultValue = defaultValue; } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Leafref.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Leafref.java index 9c99d4218a..a185d55ea6 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Leafref.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Leafref.java @@ -17,10 +17,16 @@ 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 default implementation of Instance Leafref Type Definition interface. + * + * @see LeafrefTypeDefinition + */ public class Leafref implements LeafrefTypeDefinition { private static final QName name = BaseTypes.constructQName("leafref"); - private static final String description = ""; - private static final String reference = ""; + private static final String description = "The leafref type is used to reference a " + + "particular leaf instance in the data tree."; + private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.9"; private final SchemaPath path = BaseTypes.schemaPath(name); private final RevisionAwareXPath xpath; private final String units = ""; diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/RevisionAwareXPathImpl.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/RevisionAwareXPathImpl.java index d3328f3804..ef4ea8463d 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/RevisionAwareXPathImpl.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/RevisionAwareXPathImpl.java @@ -9,6 +9,11 @@ package org.opendaylight.controller.model.util; import org.opendaylight.controller.yang.model.api.RevisionAwareXPath; +/** + * The default implementation of Instance Rewision Aware XPath interface. + * + * @see RevisionAwareXPath + */ public class RevisionAwareXPathImpl implements RevisionAwareXPath { private final String xpath; @@ -24,11 +29,6 @@ public class RevisionAwareXPathImpl implements RevisionAwareXPath { return absolute; } - @Override - public String toString() { - return xpath; - } - @Override public int hashCode() { final int prime = 31; @@ -62,5 +62,9 @@ public class RevisionAwareXPathImpl implements RevisionAwareXPath { } return false; } - + + @Override + public String toString() { + return xpath; + } } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/StringType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/StringType.java index 99b6d26684..e0acee2dd4 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/StringType.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/StringType.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.model.util; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -18,6 +19,11 @@ 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 default implementation of String Type Definition interface. + * + * @see StringTypeDefinition + */ public class StringType implements StringTypeDefinition { private final QName name = BaseTypes.constructQName("string");; @@ -29,21 +35,41 @@ public class StringType implements StringTypeDefinition { private final List patterns; private String units = ""; + /** + * Default Constructor. + */ public StringType() { super(); path = BaseTypes.schemaPath(name); - this.lengthStatements = Collections.emptyList(); + final List constraints = new ArrayList(); + constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", "")); + lengthStatements = Collections.unmodifiableList(constraints); + this.patterns = Collections.emptyList(); } - public StringType(List lengthStatements, - List patterns) { + /** + * + * + * @param lengthStatements + * @param patterns + */ + public StringType(final List lengthStatements, + final List patterns) { super(); path = BaseTypes.schemaPath(name); this.lengthStatements = Collections.unmodifiableList(lengthStatements); this.patterns = Collections.unmodifiableList(patterns); } + /** + * + * + * @param defaultValue + * @param lengthStatements + * @param patterns + * @param units + */ public StringType(final String defaultValue, final List lengthStatements, final List patterns, final String units) { diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint16.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint16.java index 5094d77bd5..a5540bf0c7 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint16.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint16.java @@ -1,59 +1,62 @@ /* - * 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 - */ + * 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.List; -import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; +import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition; import org.opendaylight.controller.yang.common.QName; -public class Uint16 extends AbstractInteger { +/** + * Implementation of Yang uint32 built-in type.
+ * uint16 represents integer values between 0 and 65535, inclusively. The Java + * counterpart of Yang uint32 built-in type is {@link Integer}. + * + */ +public class Uint16 extends AbstractUnsignedInteger { private static final QName name = BaseTypes.constructQName("uint16"); private Integer defaultValue = null; - private static final String description = ""; - private static final String reference = ""; + private static final String description = "uint16 represents integer values between 0 and 65535, inclusively."; public Uint16() { - super(name, description, reference); + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); } public Uint16(final Integer defaultValue) { - super(name, description, reference); + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); this.defaultValue = defaultValue; } public Uint16(final List rangeStatements, - final Integer defaultValue) { - super(name, description, reference, rangeStatements); - this.defaultValue = defaultValue; - } - - public Uint16(final String units, final Integer defaultValue) { - super(name, description, reference, units); + final String units, final Integer defaultValue) { + super(name, description, rangeStatements, units); this.defaultValue = defaultValue; } /* * (non-Javadoc) * - * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() + * @see + * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() */ @Override - public IntegerTypeDefinition getBaseType() { + public UnsignedIntegerTypeDefinition getBaseType() { return this; } /* * (non-Javadoc) * - * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue() + * @see + * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue + * () */ @Override public Object getDefaultValue() { diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint32.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint32.java index 48c6a47ecb..083cd7e32e 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint32.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint32.java @@ -1,59 +1,62 @@ /* - * 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 - */ + * 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.List; -import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; +import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition; import org.opendaylight.controller.yang.common.QName; -public class Uint32 extends AbstractInteger { +/** + * Implementation of Yang uint32 built-in type.
+ * uint32 represents integer values between 0 and 4294967295, inclusively. The + * Java counterpart of Yang uint32 built-in type is {@link Long}. + * + */ +public class Uint32 extends AbstractUnsignedInteger { private static final QName name = BaseTypes.constructQName("uint32"); private Long defaultValue = null; - private static final String description = ""; - private static final String reference = ""; + private static final String description = "uint32 represents integer values between 0 and 4294967295, inclusively."; public Uint32() { - super(name, description, reference); + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); } public Uint32(final Long defaultValue) { - super(name, description, reference); + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); this.defaultValue = defaultValue; } public Uint32(final List rangeStatements, - final Long defaultValue) { - super(name, description, reference, rangeStatements); - this.defaultValue = defaultValue; - } - - public Uint32(final String units, final Long defaultValue) { - super(name, description, reference, units); + final String units, final Long defaultValue) { + super(name, description, rangeStatements, units); this.defaultValue = defaultValue; } /* * (non-Javadoc) * - * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() + * @see + * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() */ @Override - public IntegerTypeDefinition getBaseType() { + public UnsignedIntegerTypeDefinition getBaseType() { return this; } /* * (non-Javadoc) * - * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue() + * @see + * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue + * () */ @Override public Object getDefaultValue() { diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint64.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint64.java index 8ac7c39aff..e17a4dc4df 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint64.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint64.java @@ -1,60 +1,65 @@ /* - * 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 - */ + * 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.math.BigInteger; import java.util.List; -import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; +import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition; import org.opendaylight.controller.yang.common.QName; -public class Uint64 extends AbstractInteger { +/** + * Implementation of Yang uint64 built-in type.
+ * uint64 represents integer values between 0 and 18446744073709551615, + * inclusively. The Java counterpart of Yang uint64 built-in type is + * {@link BigInteger}. + * + */ +public class Uint64 extends AbstractUnsignedInteger { private static final QName name = BaseTypes.constructQName("uint32"); private BigInteger defaultValue = null; - private static final String description = ""; - private static final String reference = ""; + private static final String description = + "uint64 represents integer values between 0 and 18446744073709551615, inclusively."; public Uint64() { - super(name, description, reference); + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); } public Uint64(final BigInteger defaultValue) { - super(name, description, reference); + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); this.defaultValue = defaultValue; } public Uint64(final List rangeStatements, - final BigInteger defaultValue) { - super(name, description, reference, rangeStatements); - this.defaultValue = defaultValue; - } - - public Uint64(final String units, final BigInteger defaultValue) { - super(name, description, reference, units); + final String units, final BigInteger defaultValue) { + super(name, description, rangeStatements, units); this.defaultValue = defaultValue; } /* * (non-Javadoc) * - * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() + * @see + * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() */ @Override - public IntegerTypeDefinition getBaseType() { + public UnsignedIntegerTypeDefinition getBaseType() { return this; } /* * (non-Javadoc) * - * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue() + * @see + * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue + * () */ @Override public Object getDefaultValue() { diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint8.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint8.java index 39314fe718..d4429dccb3 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint8.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Uint8.java @@ -9,40 +9,37 @@ package org.opendaylight.controller.model.util; import java.util.List; -import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; +import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition; import org.opendaylight.controller.yang.common.QName; -public class Uint8 extends AbstractInteger { +/** + * Implementation of Yang uint8 built-in type. + *
+ * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of + * Yang uint8 built-in type is {@link Short}. + * + * @see AbstractUnsignedInteger + */ +public class Uint8 extends AbstractUnsignedInteger { private static final QName name = BaseTypes.constructQName("uint8"); private Short defaultValue = null; - private static final String description = ""; - private static final String reference = ""; + private static final String description = + "uint8 represents integer values between 0 and 255, inclusively."; public Uint8() { - super(name, description, reference); + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); } public Uint8(final Short defaultValue) { - super(name, description, reference); - this.defaultValue = defaultValue; - } - - public Uint8(final List rangeStatements, - final Short defaultValue) { - super(name, description, reference, rangeStatements); - this.defaultValue = defaultValue; - } - - public Uint8(final String units, final Short defaultValue) { - super(name, description, reference, units); + super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, ""); this.defaultValue = defaultValue; } public Uint8(final List rangeStatements, final String units, final Short defaultValue) { - super(name, description, reference, units, rangeStatements); + super(name, description, rangeStatements, units); this.defaultValue = defaultValue; } @@ -52,7 +49,7 @@ public class Uint8 extends AbstractInteger { * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType() */ @Override - public IntegerTypeDefinition getBaseType() { + public UnsignedIntegerTypeDefinition getBaseType() { return this; } diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/UnknownType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/UnknownType.java index f0b5ddd286..1553ce0d76 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/UnknownType.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/UnknownType.java @@ -15,7 +15,6 @@ import org.opendaylight.controller.model.api.type.PatternConstraint; import org.opendaylight.controller.model.api.type.RangeConstraint; import org.opendaylight.controller.model.api.type.UnknownTypeDefinition; import org.opendaylight.controller.yang.common.QName; -import org.opendaylight.controller.yang.model.api.ExtensionDefinition; import org.opendaylight.controller.yang.model.api.SchemaPath; import org.opendaylight.controller.yang.model.api.Status; import org.opendaylight.controller.yang.model.api.UnknownSchemaNode; diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/YangTypesConverter.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/YangTypesConverter.java index a09d27e340..7f485c3c20 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/YangTypesConverter.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/YangTypesConverter.java @@ -20,6 +20,7 @@ import org.opendaylight.controller.model.api.type.DecimalTypeDefinition; import org.opendaylight.controller.model.api.type.IntegerTypeDefinition; import org.opendaylight.controller.model.api.type.RangeConstraint; import org.opendaylight.controller.model.api.type.StringTypeDefinition; +import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition; import org.opendaylight.controller.yang.common.QName; import org.opendaylight.controller.yang.model.api.TypeDefinition; @@ -36,10 +37,10 @@ public class YangTypesConverter { private static final TypeDefinition INT32_TYPE = new Int32(); private static final TypeDefinition INT64_TYPE = new Int64(); private static final TypeDefinition STRING_TYPE = new StringType(); - private static final TypeDefinition UINT8_TYPE = new Uint8(); - private static final TypeDefinition UINT16_TYPE = new Int16(); - private static final TypeDefinition UINT32_TYPE = new Int32(); - private static final TypeDefinition UINT64_TYPE = new Int64(); + private static final TypeDefinition UINT8_TYPE = new Uint8(); + private static final TypeDefinition UINT16_TYPE = new Uint16(); + private static final TypeDefinition UINT32_TYPE = new Uint32(); + private static final TypeDefinition UINT64_TYPE = new Uint64(); static { baseYangTypeMap.put("binary", BINARY); @@ -90,24 +91,30 @@ public class YangTypesConverter { return type; } - public static TypeDefinition javaTypeForBaseYangIntegerType( - String typeName, List ranges) { + public static TypeDefinition javaTypeForBaseYangSignedIntegerType( + String typeName) { if (typeName.equals("int8")) { - return new Int8(ranges, null); + return new Int8(); } else if (typeName.equals("int16")) { - return new Int16(ranges, null); + return new Int16(); } else if (typeName.equals("int32")) { - return new Int32(ranges, null); + return new Int32(); } else if (typeName.equals("int64")) { - return new Int64(ranges, null); - } else if (typeName.equals("uint8")) { - return new Uint8(ranges, null); + return new Int64(); + } + return null; + } + + public static TypeDefinition javaTypeForBaseYangUnsignedIntegerType( + final String typeName) { + if (typeName.equals("uint8")) { + return new Uint8(); } else if (typeName.equals("uint16")) { - return new Uint16(ranges, null); + return new Uint16(); } else if (typeName.equals("uint32")) { - return new Uint32(ranges, null); + return new Uint32(); } else if (typeName.equals("uint64")) { - return new Uint64(ranges, null); + return new Uint64(); } return null; }