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