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