Merge "Replaced Equals/HashcodeBuilder for DatapacketListener"
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / StringType.java
index f58075bf307d9d6d2bd4f2012620dc4970426c7a..018ba00042d7ec27e9ee9c182c74ea56effdb98b 100644 (file)
@@ -7,10 +7,8 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -26,9 +24,9 @@ import org.opendaylight.controller.yang.model.api.type.StringTypeDefinition;
  *
  * @see StringTypeDefinition
  */
-public class StringType implements StringTypeDefinition {
+public final class StringType implements StringTypeDefinition {
 
-    private final QName name = BaseTypes.constructQName("string");;
+    private final QName name = BaseTypes.constructQName("string");
     private final SchemaPath path;
     private String defaultValue = "";
     private final String description = "";
@@ -36,32 +34,43 @@ public class StringType implements StringTypeDefinition {
     private final List<LengthConstraint> lengthStatements;
     private final List<PatternConstraint> patterns;
     private String units = "";
+    private final StringTypeDefinition baseType;
+
+    private StringType() {
+        super();
+        path = BaseTypes.schemaPath(name);
+        final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
+        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+        lengthStatements = Collections.unmodifiableList(constraints);
+        patterns = Collections.emptyList();
+        baseType = this;
+    }
 
     /**
      * Default Constructor.
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision) {
+    public StringType(final SchemaPath path) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
         lengthStatements = Collections.unmodifiableList(constraints);
-
-        this.patterns = Collections.emptyList();
+        patterns = Collections.emptyList();
+        baseType = new StringType();
     }
 
     /**
      *
-     *
+     * @param actualPath
+     * @param namespace
+     * @param revision
      * @param lengthStatements
      * @param patterns
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision, final List<LengthConstraint> lengthStatements,
+    public StringType(final SchemaPath path, final List<LengthConstraint> lengthStatements,
             final List<PatternConstraint> patterns) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         if(lengthStatements == null || lengthStatements.size() == 0) {
             final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
             constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
@@ -70,6 +79,7 @@ public class StringType implements StringTypeDefinition {
             this.lengthStatements = Collections.unmodifiableList(lengthStatements);
         }
         this.patterns = Collections.unmodifiableList(patterns);
+        baseType = new StringType();
     }
 
     /**
@@ -80,12 +90,11 @@ public class StringType implements StringTypeDefinition {
      * @param patterns
      * @param units
      */
-    public StringType(final List<String> actualPath,
-            final URI namespace, final Date revision, final String defaultValue,
+    public StringType(final SchemaPath path, final String defaultValue,
             final List<LengthConstraint> lengthStatements,
             final List<PatternConstraint> patterns, final String units) {
         super();
-        path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.path = path;
         this.defaultValue = defaultValue;
         if(lengthStatements == null || lengthStatements.size() == 0) {
             final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
@@ -94,8 +103,9 @@ public class StringType implements StringTypeDefinition {
         } else {
             this.lengthStatements = Collections.unmodifiableList(lengthStatements);
         }
-        this.patterns = patterns;
+        this.patterns = Collections.unmodifiableList(patterns);
         this.units = units;
+        this.baseType = new StringType();
     }
 
     /*
@@ -105,7 +115,7 @@ public class StringType implements StringTypeDefinition {
      */
     @Override
     public StringTypeDefinition getBaseType() {
-        return this;
+        return baseType;
     }
 
     /*