4 package org.opendaylight.controller.yang.model.util;
6 import java.util.ArrayList;
7 import java.util.Collections;
10 import org.opendaylight.controller.yang.common.QName;
11 import org.opendaylight.controller.yang.model.api.SchemaPath;
12 import org.opendaylight.controller.yang.model.api.Status;
13 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
14 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
15 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
18 * The Abstract Integer class defines implementation of IntegerTypeDefinition
19 * interface which represents UNSIGNED Integer values defined in Yang language. <br>
20 * The integer built-in types in Yang are uint8, uint16, uint32, and uint64.
21 * They represent unsigned integers of different sizes:
24 * <li>uint8 - represents integer values between 0 and 255, inclusively.</li>
25 * <li>uint16 - represents integer values between 0 and 65535, inclusively.</li>
26 * <li>uint32 - represents integer values between 0 and 4294967295, inclusively.
28 * <li>uint64 - represents integer values between 0 and 18446744073709551615,
33 public abstract class AbstractUnsignedInteger implements
34 UnsignedIntegerTypeDefinition {
35 private final QName name;
36 private final SchemaPath path;
37 private final String description;
38 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.2";
39 private final String units;
40 private final List<RangeConstraint> rangeStatements;
53 public AbstractUnsignedInteger(final SchemaPath path, final QName name,
54 final String description, final Number minRange,
55 final Number maxRange, final String units) {
57 this.description = description;
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 SchemaPath path, final QName name,
75 final String description,
76 final List<RangeConstraint> rangeStatements, final String units) {
78 this.description = description;
81 this.rangeStatements = rangeStatements;
85 public String getUnits() {
90 public QName getQName() {
95 public SchemaPath getPath() {
100 public String getDescription() {
105 public String getReference() {
110 public Status getStatus() {
111 return Status.CURRENT;
115 public List<RangeConstraint> getRangeStatements() {
116 return rangeStatements;
120 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
121 return Collections.emptyList();
125 public int hashCode() {
126 final int prime = 31;
128 result = prime * result
129 + ((description == null) ? 0 : description.hashCode());
130 result = prime * result + ((name == null) ? 0 : name.hashCode());
131 result = prime * result + ((path == null) ? 0 : path.hashCode());
132 result = prime * result
133 + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
134 result = prime * result
135 + ((reference == null) ? 0 : reference.hashCode());
136 result = prime * result + ((units == null) ? 0 : units.hashCode());
141 public boolean equals(Object obj) {
148 if (getClass() != obj.getClass()) {
151 AbstractUnsignedInteger other = (AbstractUnsignedInteger) obj;
152 if (description == null) {
153 if (other.description != null) {
156 } else if (!description.equals(other.description)) {
160 if (other.name != null) {
163 } else if (!name.equals(other.name)) {
167 if (other.path != null) {
170 } else if (!path.equals(other.path)) {
173 if (rangeStatements == null) {
174 if (other.rangeStatements != null) {
177 } else if (!rangeStatements.equals(other.rangeStatements)) {
180 if (reference == null) {
181 if (other.reference != null) {
184 } else if (!reference.equals(other.reference)) {
188 if (other.units != null) {
191 } else if (!units.equals(other.units)) {
198 public String toString() {
199 StringBuilder builder = new StringBuilder();
200 builder.append("AbstractInteger [name=");
201 builder.append(name);
202 builder.append(", path=");
203 builder.append(path);
204 builder.append(", description=");
205 builder.append(description);
206 builder.append(", reference=");
207 builder.append(reference);
208 builder.append(", units=");
209 builder.append(units);
210 builder.append(", rangeStatements=");
211 builder.append(rangeStatements);
213 return builder.toString();