Merge "Added support for annotations in generated APIs."
[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.net.URI;
11 import java.util.Date;
12 import java.util.List;
13
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;
17
18 /**
19  * Implementation of Yang uint8 built-in type.
20  * <br>
21  * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of
22  * Yang uint8 built-in type is {@link Short}.
23  *
24  * @see AbstractUnsignedInteger
25  */
26 public class Uint8 extends AbstractUnsignedInteger {
27
28     private static final QName name = BaseTypes.constructQName("uint8");
29     private Short defaultValue = null;
30     private static final String description =
31             "uint8  represents integer values between 0 and 255, inclusively.";
32
33     public Uint8(final List<String> actualPath,
34             final URI namespace, final Date revision) {
35         super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
36     }
37
38     public Uint8(final List<String> actualPath,
39             final URI namespace, final Date revision, final Short defaultValue) {
40         super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
41         this.defaultValue = defaultValue;
42     }
43
44     public Uint8(final List<String> actualPath,
45             final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
46             final String units, final Short defaultValue) {
47         super(actualPath, namespace, revision, name, description, rangeStatements, units);
48         this.defaultValue = defaultValue;
49     }
50
51     /*
52      * (non-Javadoc)
53      *
54      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
55      */
56     @Override
57     public UnsignedIntegerTypeDefinition getBaseType() {
58         return this;
59     }
60
61     /*
62      * (non-Javadoc)
63      *
64      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
65      */
66     @Override
67     public Object getDefaultValue() {
68         return defaultValue;
69     }
70
71     @Override
72     public int hashCode() {
73         final int prime = 31;
74         int result = super.hashCode();
75         result = prime * result
76                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
77         return result;
78     }
79
80     @Override
81     public boolean equals(Object obj) {
82         if (this == obj) {
83             return true;
84         }
85         if (!super.equals(obj)) {
86             return false;
87         }
88         if (getClass() != obj.getClass()) {
89             return false;
90         }
91         Uint8 other = (Uint8) obj;
92         if (defaultValue == null) {
93             if (other.defaultValue != null) {
94                 return false;
95             }
96         } else if (!defaultValue.equals(other.defaultValue)) {
97             return false;
98         }
99         return true;
100     }
101
102     @Override
103     public String toString() {
104         StringBuilder builder = new StringBuilder();
105         builder.append("Uint8 [defaultValue=");
106         builder.append(defaultValue);
107         builder.append(", AbstractInteger=");
108         builder.append(super.toString());
109         builder.append("]");
110         return builder.toString();
111     }
112 }