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 / BitsType.java
index e6c118934e72ef78f9e958b21765f36a56fe5720..94391d2288eace0dc4b6d9265d97ee06893e2dcb 100644 (file)
@@ -1,10 +1,10 @@
 /*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.yang.model.util;
 
 import java.util.Collections;
@@ -16,75 +16,64 @@ import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
 
-
 /**
  * The <code>default</code> implementation of Bits Type Definition interface.
- * 
+ *
  * @see BitsTypeDefinition
  */
-public class BitsType implements BitsTypeDefinition {
-
+public final class BitsType implements BitsTypeDefinition {
     private final QName name = BaseTypes.constructQName("bits");
-    private final SchemaPath path = BaseTypes.schemaPath(name);
-    private final String description = "The bits built-in type represents a bit set.  " +
-               "That is, a bits value is a set of flags identified by small integer position " +
-               "numbers starting at 0.  Each bit number has an assigned name.";
-    
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
+    private final SchemaPath path;
+    private final String description = "The bits built-in type represents a bit set.  "
+            + "That is, a bits value is a set of flags identified by small integer position "
+            + "numbers starting at 0.  Each bit number has an assigned name.";
 
+    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
+    private final BitsTypeDefinition baseType;
     private final List<Bit> bits;
-    private String units = "";
+    private final String units = "";
 
     /**
      * Default constructor. <br>
      * Instantiates Bits type as empty bits list.
      */
-    public BitsType() {
+    public BitsType(final SchemaPath path) {
         super();
-        bits = Collections.emptyList();
+        this.bits = Collections.emptyList();
+        this.path = path;
+        this.baseType = this;
     }
 
     /**
-     * Constructor with explicit definition of bits assigned to
-     * BitsType.
-     * 
+     * Constructor with explicit definition of bits assigned to BitsType.
+     *
+     * @param actualPath
+     * @param namespace
+     * @param revision
      * @param bits
      *            The bits assigned for Bits Type
      */
-    public BitsType(final List<Bit> bits) {
-        super();
-        this.bits = Collections.unmodifiableList(bits);
-        this.units = "";
-    }
-
-    /**
-     * Constructor with explicit definition of bits assigned to
-     * BitsType and Units.
-     * <br>
-     * The default value of Bits Type is List of bits.
-     * 
-     * @param bits The bits assigned for Bits Type
-     * @param units units for bits type
-     */
-    public BitsType(List<Bit> bits, String units) {
+    public BitsType(final SchemaPath path, final List<Bit> bits) {
         super();
         this.bits = Collections.unmodifiableList(bits);
-        this.units = units;
+        this.path = path;
+        this.baseType = this;
     }
 
     /*
      * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
      */
     @Override
     public BitsTypeDefinition getBaseType() {
-        return this;
+        return baseType;
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
      */
     @Override
@@ -94,8 +83,10 @@ public class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
      */
     @Override
     public Object getDefaultValue() {
@@ -104,7 +95,7 @@ public class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
      */
     @Override
@@ -114,7 +105,7 @@ public class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
      */
     @Override
@@ -124,8 +115,9 @@ public class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
      */
     @Override
     public String getDescription() {
@@ -134,7 +126,7 @@ public class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
      */
     @Override
@@ -144,7 +136,7 @@ public class BitsType implements BitsTypeDefinition {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
      */
     @Override