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 / Uint8.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 uint8 built-in type.
18  * <br>
19  * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of 
20  * Yang uint8 built-in type is {@link Short}.
21  * 
22  * @see AbstractUnsignedInteger
23  */
24 public class Uint8 extends AbstractUnsignedInteger {
25
26     private static final QName name = BaseTypes.constructQName("uint8");
27     private Short defaultValue = null;
28     private static final String description = 
29             "uint8  represents integer values between 0 and 255, inclusively.";
30
31     public Uint8() {
32         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
33     }
34
35     public Uint8(final Short defaultValue) {
36         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
37         this.defaultValue = defaultValue;
38     }
39
40     public Uint8(final List<RangeConstraint> rangeStatements,
41             final String units, final Short defaultValue) {
42         super(name, description, rangeStatements, units);
43         this.defaultValue = defaultValue;
44     }
45
46     /*
47      * (non-Javadoc)
48      * 
49      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
50      */
51     @Override
52     public UnsignedIntegerTypeDefinition getBaseType() {
53         return this;
54     }
55
56     /*
57      * (non-Javadoc)
58      * 
59      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
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         Uint8 other = (Uint8) 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("Uint8 [defaultValue=");
101         builder.append(defaultValue);
102         builder.append(", AbstractInteger=");
103         builder.append(super.toString());
104         builder.append("]");
105         return builder.toString();
106     }
107 }