Refactored base yang-java types.
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / EmptyType.java
index 3648a179be34c8e26eac2a1c93e6c4d3da3de981..4a1200e129c1cbd28c2cee4f97ed7c3ee54d62e1 100644 (file)
@@ -17,20 +17,25 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 
 public final class EmptyType implements EmptyTypeDefinition {
-    private final QName name = BaseTypes.constructQName("empty");
-    private final SchemaPath path;
-    private final String description = "The empty built-in type represents a leaf that does not have any value, it conveys information by its presence or absence.";
-    private final String reference = "https://tools.ietf.org/html/rfc6020#page-131";
-    private final EmptyTypeDefinition baseType;
-
-    public EmptyType(final SchemaPath path) {
-        this.path = path;
-        this.baseType = this;
+    private static EmptyType INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("empty");
+    private static final SchemaPath path = new SchemaPath(Collections.singletonList(NAME), true);
+    private static final String description = "The empty built-in type represents a leaf that does not have any value, it conveys information by its presence or absence.";
+    private static final String reference = "https://tools.ietf.org/html/rfc6020#page-131";
+
+    private EmptyType() {
+    }
+
+    public static EmptyType getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new EmptyType();
+        }
+        return INSTANCE;
     }
 
     @Override
     public EmptyTypeDefinition getBaseType() {
-        return baseType;
+        return this;
     }
 
     @Override
@@ -45,7 +50,7 @@ public final class EmptyType implements EmptyTypeDefinition {
 
     @Override
     public QName getQName() {
-        return name;
+        return NAME;
     }
 
     @Override
@@ -73,4 +78,9 @@ public final class EmptyType implements EmptyTypeDefinition {
         return Collections.emptyList();
     }
 
+    @Override
+    public String toString() {
+        return "type empty " + NAME;
+    }
+
 }