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