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