4 package org.opendaylight.controller.yang.model.util;
7 import java.util.ArrayList;
8 import java.util.Collections;
10 import java.util.List;
12 import org.opendaylight.controller.yang.common.QName;
13 import org.opendaylight.controller.yang.model.api.SchemaPath;
14 import org.opendaylight.controller.yang.model.api.Status;
15 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
16 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
17 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
20 * The Abstract Integer class defines implementation of IntegerTypeDefinition
21 * interface which represents UNSIGNED Integer values defined in Yang language. <br>
22 * The integer built-in types in Yang are uint8, uint16, uint32, and uint64.
23 * They represent unsigned integers of different sizes:
26 * <li>uint8 - represents integer values between 0 and 255, inclusively.</li>
27 * <li>uint16 - represents integer values between 0 and 65535, inclusively.</li>
28 * <li>uint32 - represents integer values between 0 and 4294967295, inclusively.
30 * <li>uint64 - represents integer values between 0 and 18446744073709551615,
35 public abstract class AbstractUnsignedInteger implements
36 UnsignedIntegerTypeDefinition {
37 private final QName name;
38 private final SchemaPath path;
39 private final String description;
40 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.2";
42 private final String units;
43 private final List<RangeConstraint> rangeStatements;
52 public AbstractUnsignedInteger(final List<String> actualPath,
53 final URI namespace, final Date revision, final QName name,
54 final String description, final Number minRange,
55 final Number maxRange, final String units) {
57 this.description = description;
58 this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
60 this.rangeStatements = new ArrayList<RangeConstraint>();
61 final String rangeDescription = "Integer values between " + minRange
62 + " and " + maxRange + ", inclusively.";
63 this.rangeStatements.add(BaseConstraints.rangeConstraint(minRange,
64 maxRange, rangeDescription,
65 "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
71 * @param rangeStatements
74 public AbstractUnsignedInteger(final List<String> actualPath,
75 final URI namespace, final Date revision, final QName name,
76 final String description,
77 final List<RangeConstraint> rangeStatements, final String units) {
79 this.description = description;
80 this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
82 this.rangeStatements = rangeStatements;
86 public String getUnits() {
91 public QName getQName() {
96 public SchemaPath getPath() {
101 public String getDescription() {
106 public String getReference() {
111 public Status getStatus() {
112 return Status.CURRENT;
116 public List<RangeConstraint> getRangeStatements() {
117 return rangeStatements;
121 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
122 return Collections.emptyList();
126 public int hashCode() {
127 final int prime = 31;
129 result = prime * result
130 + ((description == null) ? 0 : description.hashCode());
131 result = prime * result + ((name == null) ? 0 : name.hashCode());
132 result = prime * result + ((path == null) ? 0 : path.hashCode());
133 result = prime * result
134 + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
135 result = prime * result
136 + ((reference == null) ? 0 : reference.hashCode());
137 result = prime * result + ((units == null) ? 0 : units.hashCode());
142 public boolean equals(Object obj) {
149 if (getClass() != obj.getClass()) {
152 AbstractUnsignedInteger other = (AbstractUnsignedInteger) obj;
153 if (description == null) {
154 if (other.description != null) {
157 } else if (!description.equals(other.description)) {
161 if (other.name != null) {
164 } else if (!name.equals(other.name)) {
168 if (other.path != null) {
171 } else if (!path.equals(other.path)) {
174 if (rangeStatements == null) {
175 if (other.rangeStatements != null) {
178 } else if (!rangeStatements.equals(other.rangeStatements)) {
181 if (reference == null) {
182 if (other.reference != null) {
185 } else if (!reference.equals(other.reference)) {
189 if (other.units != null) {
192 } else if (!units.equals(other.units)) {
199 public String toString() {
200 StringBuilder builder = new StringBuilder();
201 builder.append("AbstractInteger [name=");
202 builder.append(name);
203 builder.append(", path=");
204 builder.append(path);
205 builder.append(", description=");
206 builder.append(description);
207 builder.append(", reference=");
208 builder.append(reference);
209 builder.append(", units=");
210 builder.append(units);
211 builder.append(", rangeStatements=");
212 builder.append(rangeStatements);
214 return builder.toString();