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 / BinaryType.java
index 74214dc0c77973a9f5b07777ea77d0735c33f9fc..ea09b65b5daa1382847faff9a4429eadee79d5fd 100644 (file)
@@ -24,65 +24,33 @@ import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
  * @see BinaryTypeDefinition
  */
 public final class BinaryType implements BinaryTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("binary");
     private final SchemaPath path;
     private final String description = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.8";
     private final BinaryTypeDefinition baseType;
-    private List<Byte> bytes;
+    private final List<Byte> bytes;
     private final List<LengthConstraint> lengthConstraints;
-    private String units = "";
-
-    private BinaryType() {
-        super();
+    private final String units = "";
 
+    public BinaryType(final SchemaPath path) {
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
                 ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
         this.bytes = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(name);
+        this.path = path;
         this.baseType = this;
     }
 
-    public BinaryType(final SchemaPath path) {
-        super();
-
+    public BinaryType(final SchemaPath path, final List<Byte> bytes) {
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
                 ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
-        this.bytes = Collections.emptyList();
-        this.path = path;
-        this.baseType = new BinaryType();
-    }
-
-    /**
-     *
-     *
-     * @param bytes
-     * @param lengthConstraints
-     * @param units
-     */
-    public BinaryType(final SchemaPath path, final List<Byte> bytes,
-            final List<LengthConstraint> lengthConstraints, final String units) {
-        super();
-
-        if ((lengthConstraints == null) || (lengthConstraints.isEmpty())) {
-            final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-            constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE,
-                    "", ""));
-            this.lengthConstraints = Collections.unmodifiableList(constraints);
-        } else {
-            this.lengthConstraints = Collections
-                    .unmodifiableList(lengthConstraints);
-        }
-
-        this.path = path;
         this.bytes = Collections.unmodifiableList(bytes);
-        this.units = units;
-        this.baseType = new BinaryType();
+        this.path = path;
+        this.baseType = this;
     }
 
     /*