Fixed bugs in naming conventions of packages.
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / Int16.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.IntegerTypeDefinition;
14 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
15
16 /**
17  * Implementation of Yang int16 built-in type. <br>
18  * int16 represents integer values between -32768 and 32767, inclusively. The
19  * Java counterpart of Yang int16 built-in type is {@link Short}.
20  * 
21  * @see AbstractSignedInteger
22  */
23 public class Int16 extends AbstractSignedInteger {
24
25     private static final QName name = BaseTypes.constructQName("int16");
26     private Short defaultValue = null;
27     private static final String description = 
28             "int16  represents integer values between -32768 and 32767, inclusively.";
29
30     public Int16() {
31         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
32     }
33
34     public Int16(final List<RangeConstraint> rangeStatements,
35             final String units, final Short defaultValue) {
36         super(name, description, rangeStatements, units);
37         this.defaultValue = defaultValue;
38     }
39
40     @Override
41     public IntegerTypeDefinition getBaseType() {
42         return this;
43     }
44
45     @Override
46     public Object getDefaultValue() {
47         return defaultValue;
48     }
49
50     @Override
51     public int hashCode() {
52         final int prime = 31;
53         int result = super.hashCode();
54         result = prime * result
55                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
56         return result;
57     }
58
59     @Override
60     public boolean equals(Object obj) {
61         if (this == obj) {
62             return true;
63         }
64         if (!super.equals(obj)) {
65             return false;
66         }
67         if (getClass() != obj.getClass()) {
68             return false;
69         }
70         Int16 other = (Int16) obj;
71         if (defaultValue == null) {
72             if (other.defaultValue != null) {
73                 return false;
74             }
75         } else if (!defaultValue.equals(other.defaultValue)) {
76             return false;
77         }
78         return true;
79     }
80
81     @Override
82     public String toString() {
83         StringBuilder builder = new StringBuilder();
84         builder.append("Int16 [defaultValue=");
85         builder.append(defaultValue);
86         builder.append(", AbstractInteger=");
87         builder.append(super.toString());
88         builder.append("]");
89         return builder.toString();
90     }
91 }