2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.yang.model.util;
11 import java.util.Date;
12 import java.util.List;
14 import org.opendaylight.controller.yang.common.QName;
15 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
16 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
19 * Implementation of Yang uint32 built-in type. <br>
20 * uint16 represents integer values between 0 and 65535, inclusively. The Java
21 * counterpart of Yang uint32 built-in type is {@link Integer}.
24 public class Uint16 extends AbstractUnsignedInteger {
26 private static final QName name = BaseTypes.constructQName("uint16");
27 private Integer defaultValue = null;
28 private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";
29 private final UnsignedIntegerTypeDefinition baseType;
32 super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
36 public Uint16(final List<String> actualPath,
37 final URI namespace, final Date revision) {
38 super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
39 this.baseType = new Uint16();
42 public Uint16(final List<String> actualPath,
43 final URI namespace, final Date revision, final Integer defaultValue) {
44 super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
45 this.baseType = new Uint16();
46 this.defaultValue = defaultValue;
49 public Uint16(final List<String> actualPath,
50 final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
51 final String units, final Integer defaultValue) {
52 super(actualPath, namespace, revision, name, description, rangeStatements, units);
53 this.baseType = new Uint16();
54 this.defaultValue = defaultValue;
61 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
64 public UnsignedIntegerTypeDefinition getBaseType() {
72 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
76 public Object getDefaultValue() {
81 public int hashCode() {
83 int result = super.hashCode();
84 result = prime * result
85 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
90 public boolean equals(Object obj) {
94 if (!super.equals(obj)) {
97 if (getClass() != obj.getClass()) {
100 Uint16 other = (Uint16) obj;
101 if (defaultValue == null) {
102 if (other.defaultValue != null) {
105 } else if (!defaultValue.equals(other.defaultValue)) {
112 public String toString() {
113 StringBuilder builder = new StringBuilder();
114 builder.append("Uint16 [defaultValue=");
115 builder.append(defaultValue);
116 builder.append(", AbstractInteger=");
117 builder.append(super.toString());
119 return builder.toString();