Merge "Fix for messags at the boot up time This commit proposes following two sets...
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / Uint16.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.yang.model.util;
9
10 import java.util.List;
11
12 import org.opendaylight.controller.yang.common.QName;
13 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
14 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
15
16 /**
17  * Implementation of Yang uint32 built-in type. <br>
18  * uint16 represents integer values between 0 and 65535, inclusively. The Java
19  * counterpart of Yang uint32 built-in type is {@link Integer}.
20  * 
21  */
22 public class Uint16 extends AbstractUnsignedInteger {
23
24     private static final QName name = BaseTypes.constructQName("uint16");
25     private Integer defaultValue = null;
26     private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";
27
28     public Uint16() {
29         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
30     }
31
32     public Uint16(final Integer defaultValue) {
33         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
34         this.defaultValue = defaultValue;
35     }
36
37     public Uint16(final List<RangeConstraint> rangeStatements,
38             final String units, final Integer defaultValue) {
39         super(name, description, rangeStatements, units);
40         this.defaultValue = defaultValue;
41     }
42
43     /*
44      * (non-Javadoc)
45      * 
46      * @see
47      * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
48      */
49     @Override
50     public UnsignedIntegerTypeDefinition getBaseType() {
51         return this;
52     }
53
54     /*
55      * (non-Javadoc)
56      * 
57      * @see
58      * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
59      * ()
60      */
61     @Override
62     public Object getDefaultValue() {
63         return defaultValue;
64     }
65
66     @Override
67     public int hashCode() {
68         final int prime = 31;
69         int result = super.hashCode();
70         result = prime * result
71                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
72         return result;
73     }
74
75     @Override
76     public boolean equals(Object obj) {
77         if (this == obj) {
78             return true;
79         }
80         if (!super.equals(obj)) {
81             return false;
82         }
83         if (getClass() != obj.getClass()) {
84             return false;
85         }
86         Uint16 other = (Uint16) obj;
87         if (defaultValue == null) {
88             if (other.defaultValue != null) {
89                 return false;
90             }
91         } else if (!defaultValue.equals(other.defaultValue)) {
92             return false;
93         }
94         return true;
95     }
96
97     @Override
98     public String toString() {
99         StringBuilder builder = new StringBuilder();
100         builder.append("Uint16 [defaultValue=");
101         builder.append(defaultValue);
102         builder.append(", AbstractInteger=");
103         builder.append(super.toString());
104         builder.append("]");
105         return builder.toString();
106     }
107 }