2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.controller.model.util;
\r
10 import java.util.Collections;
\r
11 import java.util.List;
\r
13 import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;
\r
14 import org.opendaylight.controller.model.api.type.RangeConstraint;
\r
15 import org.opendaylight.controller.yang.common.QName;
\r
16 import org.opendaylight.controller.yang.model.api.SchemaPath;
\r
17 import org.opendaylight.controller.yang.model.api.Status;
\r
18 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
\r
20 public abstract class AbstractInteger implements IntegerTypeDefinition {
\r
22 private final QName name;
\r
23 private final SchemaPath path;
\r
25 private final String description;
\r
26 private final String reference;
\r
28 private String units = "";
\r
29 private final List<RangeConstraint> rangeStatements;
\r
31 public AbstractInteger(final QName name, final String description,
\r
32 final String reference) {
\r
35 this.description = description;
\r
36 this.reference = reference;
\r
37 this.path = BaseTypes.schemaPath(name);
\r
39 final List<? extends RangeConstraint> emptyContstraints = Collections
\r
41 this.rangeStatements = Collections.unmodifiableList(emptyContstraints);
\r
44 public AbstractInteger(QName name, String description, String reference,
\r
45 List<RangeConstraint> rangeStatements) {
\r
48 this.description = description;
\r
49 this.reference = reference;
\r
50 this.rangeStatements = rangeStatements;
\r
51 this.path = BaseTypes.schemaPath(name);
\r
54 public AbstractInteger(QName name, String description, String reference,
\r
58 this.description = description;
\r
59 this.reference = reference;
\r
61 this.path = BaseTypes.schemaPath(name);
\r
63 final List<? extends RangeConstraint> emptyContstraints = Collections
\r
65 this.rangeStatements = Collections.unmodifiableList(emptyContstraints);
\r
68 public AbstractInteger(QName name, String description, String reference,
\r
69 String units, List<RangeConstraint> rangeStatements) {
\r
72 this.description = description;
\r
73 this.reference = reference;
\r
75 this.rangeStatements = rangeStatements;
\r
76 this.path = BaseTypes.schemaPath(name);
\r
80 public String getUnits() {
\r
85 public QName getQName() {
\r
90 public SchemaPath getPath() {
\r
95 public String getDescription() {
\r
100 public String getReference() {
\r
105 public Status getStatus() {
\r
106 return Status.CURRENT;
\r
110 public List<RangeConstraint> getRangeStatements() {
\r
111 return rangeStatements;
\r
115 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
\r
116 return Collections.emptyList();
\r
120 public int hashCode() {
\r
121 final int prime = 31;
\r
123 result = prime * result
\r
124 + ((description == null) ? 0 : description.hashCode());
\r
125 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
126 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
127 result = prime * result
\r
128 + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
\r
129 result = prime * result
\r
130 + ((reference == null) ? 0 : reference.hashCode());
\r
131 result = prime * result + ((units == null) ? 0 : units.hashCode());
\r
136 public boolean equals(Object obj) {
\r
143 if (getClass() != obj.getClass()) {
\r
146 AbstractInteger other = (AbstractInteger) obj;
\r
147 if (description == null) {
\r
148 if (other.description != null) {
\r
151 } else if (!description.equals(other.description)) {
\r
154 if (name == null) {
\r
155 if (other.name != null) {
\r
158 } else if (!name.equals(other.name)) {
\r
161 if (path == null) {
\r
162 if (other.path != null) {
\r
165 } else if (!path.equals(other.path)) {
\r
168 if (rangeStatements == null) {
\r
169 if (other.rangeStatements != null) {
\r
172 } else if (!rangeStatements.equals(other.rangeStatements)) {
\r
175 if (reference == null) {
\r
176 if (other.reference != null) {
\r
179 } else if (!reference.equals(other.reference)) {
\r
182 if (units == null) {
\r
183 if (other.units != null) {
\r
186 } else if (!units.equals(other.units)) {
\r
193 public String toString() {
\r
194 StringBuilder builder = new StringBuilder();
\r
195 builder.append("AbstractInteger [name=");
\r
196 builder.append(name);
\r
197 builder.append(", path=");
\r
198 builder.append(path);
\r
199 builder.append(", description=");
\r
200 builder.append(description);
\r
201 builder.append(", reference=");
\r
202 builder.append(reference);
\r
203 builder.append(", units=");
\r
204 builder.append(units);
\r
205 builder.append(", rangeStatements=");
\r
206 builder.append(rangeStatements);
\r
207 builder.append("]");
\r
208 return builder.toString();
\r