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.LengthConstraint;
\r
14 import org.opendaylight.controller.model.api.type.PatternConstraint;
\r
15 import org.opendaylight.controller.model.api.type.StringTypeDefinition;
\r
16 import org.opendaylight.controller.yang.common.QName;
\r
17 import org.opendaylight.controller.yang.model.api.SchemaPath;
\r
18 import org.opendaylight.controller.yang.model.api.Status;
\r
19 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
\r
21 public class StringType implements StringTypeDefinition {
\r
23 private final QName name = BaseTypes.constructQName("string");;
\r
24 private final SchemaPath path;
\r
25 private String defaultValue = "";
\r
26 private final String description = "";
\r
27 private final String reference = "";
\r
28 private final List<LengthConstraint> lengthStatements;
\r
29 private final List<PatternConstraint> patterns;
\r
30 private String units = "";
\r
32 public StringType() {
\r
34 path = BaseTypes.schemaPath(name);
\r
35 this.lengthStatements = Collections.emptyList();
\r
36 this.patterns = Collections.emptyList();
\r
39 public StringType(List<LengthConstraint> lengthStatements,
\r
40 List<PatternConstraint> patterns) {
\r
42 path = BaseTypes.schemaPath(name);
\r
43 this.lengthStatements = Collections.unmodifiableList(lengthStatements);
\r
44 this.patterns = Collections.unmodifiableList(patterns);
\r
47 public StringType(final String defaultValue,
\r
48 final List<LengthConstraint> lengthStatements,
\r
49 final List<PatternConstraint> patterns, final String units) {
\r
51 path = BaseTypes.schemaPath(name);
\r
52 this.defaultValue = defaultValue;
\r
53 this.lengthStatements = lengthStatements;
\r
54 this.patterns = patterns;
\r
61 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
64 public StringTypeDefinition getBaseType() {
\r
71 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
\r
74 public String getUnits() {
\r
81 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
\r
84 public Object getDefaultValue() {
\r
85 return defaultValue;
\r
91 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
\r
94 public QName getQName() {
\r
101 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
\r
104 public SchemaPath getPath() {
\r
111 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
\r
114 public String getDescription() {
\r
115 return description;
\r
121 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
\r
124 public String getReference() {
\r
131 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
\r
134 public Status getStatus() {
\r
135 return Status.CURRENT;
\r
142 * com.csico.yang.model.base.type.api.StringTypeDefinition#getLengthStatements
\r
146 public List<LengthConstraint> getLengthStatements() {
\r
147 return lengthStatements;
\r
154 * com.csico.yang.model.base.type.api.StringTypeDefinition#getPatterns()
\r
157 public List<PatternConstraint> getPatterns() {
\r
162 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
\r
163 return Collections.emptyList();
\r
167 public int hashCode() {
\r
168 final int prime = 31;
\r
170 result = prime * result
\r
171 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
\r
172 result = prime * result
\r
173 + ((description == null) ? 0 : description.hashCode());
\r
176 + ((lengthStatements == null) ? 0 : lengthStatements.hashCode());
\r
177 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
178 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
179 result = prime * result
\r
180 + ((patterns == null) ? 0 : patterns.hashCode());
\r
181 result = prime * result
\r
182 + ((reference == null) ? 0 : reference.hashCode());
\r
183 result = prime * result + ((units == null) ? 0 : units.hashCode());
\r
188 public boolean equals(Object obj) {
\r
195 if (getClass() != obj.getClass()) {
\r
198 StringType other = (StringType) obj;
\r
199 if (defaultValue == null) {
\r
200 if (other.defaultValue != null) {
\r
203 } else if (!defaultValue.equals(other.defaultValue)) {
\r
206 if (description == null) {
\r
207 if (other.description != null) {
\r
210 } else if (!description.equals(other.description)) {
\r
213 if (lengthStatements == null) {
\r
214 if (other.lengthStatements != null) {
\r
217 } else if (!lengthStatements.equals(other.lengthStatements)) {
\r
220 if (name == null) {
\r
221 if (other.name != null) {
\r
224 } else if (!name.equals(other.name)) {
\r
227 if (path == null) {
\r
228 if (other.path != null) {
\r
231 } else if ((path != null) && (other.path != null)) {
\r
232 if (!path.getPath().equals(other.path.getPath())) {
\r
236 if (patterns == null) {
\r
237 if (other.patterns != null) {
\r
240 } else if (!patterns.equals(other.patterns)) {
\r
243 if (reference == null) {
\r
244 if (other.reference != null) {
\r
247 } else if (!reference.equals(other.reference)) {
\r
250 if (units == null) {
\r
251 if (other.units != null) {
\r
254 } else if (!units.equals(other.units)) {
\r
261 public String toString() {
\r
262 StringBuilder builder = new StringBuilder();
\r
263 builder.append("StringType [name=");
\r
264 builder.append(name);
\r
265 builder.append(", path=");
\r
266 builder.append(path);
\r
267 builder.append(", defaultValue=");
\r
268 builder.append(defaultValue);
\r
269 builder.append(", description=");
\r
270 builder.append(description);
\r
271 builder.append(", reference=");
\r
272 builder.append(reference);
\r
273 builder.append(", lengthStatements=");
\r
274 builder.append(lengthStatements);
\r
275 builder.append(", patterns=");
\r
276 builder.append(patterns);
\r
277 builder.append(", units=");
\r
278 builder.append(units);
\r
279 builder.append("]");
\r
280 return builder.toString();
\r