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