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.List;
\r
12 import org.opendaylight.controller.model.api.type.RangeConstraint;
\r
13 import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition;
\r
14 import org.opendaylight.controller.yang.common.QName;
\r
17 * Implementation of Yang uint32 built-in type. <br>
\r
18 * uint16 represents integer values between 0 and 65535, inclusively. The Java
\r
19 * counterpart of Yang uint32 built-in type is {@link Integer}.
\r
22 public class Uint16 extends AbstractUnsignedInteger {
\r
24 private static final QName name = BaseTypes.constructQName("uint16");
\r
25 private Integer defaultValue = null;
\r
26 private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";
\r
29 super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
\r
32 public Uint16(final Integer defaultValue) {
\r
33 super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
\r
34 this.defaultValue = defaultValue;
\r
37 public Uint16(final List<RangeConstraint> rangeStatements,
\r
38 final String units, final Integer defaultValue) {
\r
39 super(name, description, rangeStatements, units);
\r
40 this.defaultValue = defaultValue;
\r
47 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
50 public UnsignedIntegerTypeDefinition getBaseType() {
\r
58 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
\r
62 public Object getDefaultValue() {
\r
63 return defaultValue;
\r
67 public int hashCode() {
\r
68 final int prime = 31;
\r
69 int result = super.hashCode();
\r
70 result = prime * result
\r
71 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
\r
76 public boolean equals(Object obj) {
\r
80 if (!super.equals(obj)) {
\r
83 if (getClass() != obj.getClass()) {
\r
86 Uint16 other = (Uint16) obj;
\r
87 if (defaultValue == null) {
\r
88 if (other.defaultValue != null) {
\r
91 } else if (!defaultValue.equals(other.defaultValue)) {
\r
98 public String toString() {
\r
99 StringBuilder builder = new StringBuilder();
\r
100 builder.append("Uint16 [defaultValue=");
\r
101 builder.append(defaultValue);
\r
102 builder.append(", AbstractInteger=");
\r
103 builder.append(super.toString());
\r
104 builder.append("]");
\r
105 return builder.toString();
\r