Refactored base yang-java types.
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / Int8.java
index cd295f14402f8c23512a6690b1785b301a769c21..537eef44de1f66fc02e0cc67c39dd0ef4bda1ff4 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
 /**
@@ -19,78 +18,34 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
  * @see AbstractSignedInteger
  */
 public final class Int8 extends AbstractSignedInteger {
-    private static final QName name = BaseTypes.constructQName("int8");
-    private final Byte defaultValue = null;
-    private static final String description = "represents integer values between -128 and 127, inclusively.";
-    private final IntegerTypeDefinition baseType;
+    private static Int8 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("int8");
+    private static final String DESCRIPTION = "represents integer values between -128 and 127, inclusively.";
 
-    public Int8(final SchemaPath path) {
-        super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
-        this.baseType = this;
+    private Int8() {
+        super(NAME, DESCRIPTION, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public IntegerTypeDefinition getBaseType() {
-        return baseType;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
-     * ()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Int8 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Int8();
+        }
+        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 IntegerTypeDefinition 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;
-        }
-        Int8 other = (Int8) 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("Int8 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
+
 }