Refactored base yang-java types.
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / Uint64.java
index 7f9dc656055e40ff1baa93ec816b4bb0c1b993d7..078b569e15293ac2f7377872de8f7c4cfbb59530 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.model.util;
 import java.math.BigInteger;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
@@ -22,78 +21,34 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  */
 public final class Uint64 extends AbstractUnsignedInteger {
     public static final BigInteger MAX_VALUE = new BigInteger("18446744073709551615");
-    private static final QName name = BaseTypes.constructQName("uint64");
-    private final BigInteger defaultValue = null;
-    private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
-    private final UnsignedIntegerTypeDefinition baseType;
+    private static Uint64 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("uint64");
+    private static final String DESCRIPTION = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
 
-    public Uint64(final SchemaPath path) {
-        super(path, name, description, MAX_VALUE, "");
-        this.baseType = this;
+    private Uint64() {
+        super(NAME, DESCRIPTION, MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public UnsignedIntegerTypeDefinition getBaseType() {
-        return baseType;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
-     * ()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Uint64 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Uint64();
+        }
+        return INSTANCE;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
+    public UnsignedIntegerTypeDefinition getBaseType() {
+        return this;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Uint64 other = (Uint64) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+    public Object getDefaultValue() {
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Uint64 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
 
 }