Replaced Equals/HashcodeBuilder for DatapacketListener
[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     private final UnsignedIntegerTypeDefinition baseType;
30
31     private Uint32() {
32         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
33         this.baseType = this;
34     }
35
36     public Uint32(final List<String> actualPath,
37             final URI namespace, final Date revision) {
38         super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
39         this.baseType = new Uint32();
40     }
41
42     public Uint32(final List<String> actualPath,
43             final URI namespace, final Date revision, final Long defaultValue) {
44         super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
45         this.baseType = new Uint32();
46         this.defaultValue = defaultValue;
47     }
48
49     public Uint32(final List<String> actualPath,
50             final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
51             final String units, final Long defaultValue) {
52         super(actualPath, namespace, revision, name, description, rangeStatements, units);
53         this.baseType = new Uint32();
54         this.defaultValue = defaultValue;
55     }
56
57     /*
58      * (non-Javadoc)
59      *
60      * @see
61      * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
62      */
63     @Override
64     public UnsignedIntegerTypeDefinition getBaseType() {
65         return baseType;
66     }
67
68     /*
69      * (non-Javadoc)
70      *
71      * @see
72      * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
73      * ()
74      */
75     @Override
76     public Object getDefaultValue() {
77         return defaultValue;
78     }
79
80     @Override
81     public int hashCode() {
82         final int prime = 31;
83         int result = super.hashCode();
84         result = prime * result
85                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
86         return result;
87     }
88
89     @Override
90     public boolean equals(Object obj) {
91         if (this == obj) {
92             return true;
93         }
94         if (!super.equals(obj)) {
95             return false;
96         }
97         if (getClass() != obj.getClass()) {
98             return false;
99         }
100         Uint32 other = (Uint32) obj;
101         if (defaultValue == null) {
102             if (other.defaultValue != null) {
103                 return false;
104             }
105         } else if (!defaultValue.equals(other.defaultValue)) {
106             return false;
107         }
108         return true;
109     }
110
111     @Override
112     public String toString() {
113         StringBuilder builder = new StringBuilder();
114         builder.append("Uint32 [defaultValue=");
115         builder.append(defaultValue);
116         builder.append(", AbstractInteger=");
117         builder.append(super.toString());
118         builder.append("]");
119         return builder.toString();
120     }
121 }