Merge "Prevent stub and integrationtest plugins to go into the distribution of openda...
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / Decimal64.java
index a1073c60cf598d768d3cfd488896d81f0bb82ed2..adb4c1a3cb00a21f6993c4de9e8140cc86d29674 100644 (file)
@@ -8,8 +8,10 @@
 package org.opendaylight.controller.yang.model.util;
 
 import java.math.BigDecimal;
+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;
@@ -21,8 +23,8 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
 /**
  * The <code>default</code> implementation of Decimal Type Definition interface.
- * 
- * 
+ *
+ *
  * @see DecimalTypeDefinition
  */
 public class Decimal64 implements DecimalTypeDefinition {
@@ -41,6 +43,7 @@ public class Decimal64 implements DecimalTypeDefinition {
 
     private final List<RangeConstraint> rangeStatements;
     private final Integer fractionDigits;
+    private final DecimalTypeDefinition baseType;
 
     /**
      * Default Decimal64 Type Constructor. <br>
@@ -52,14 +55,26 @@ public class Decimal64 implements DecimalTypeDefinition {
      * inclusively as defined interface {@link DecimalTypeDefinition} <br>
      * If the fraction digits are not defined inner the definition boundaries
      * the constructor will throw {@link IllegalArgumentException}
-     * 
+     *
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
-     * 
+     *
      * @see DecimalTypeDefinition
      * @exception IllegalArgumentException
      */
-    public Decimal64(final Integer fractionDigits) {
+    private Decimal64(final Integer fractionDigits) {
+        if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
+            throw new IllegalArgumentException(
+                    "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
+        }
+        this.fractionDigits = fractionDigits;
+        this.rangeStatements = defaultRangeStatements();
+        this.path = BaseTypes.schemaPath(name);
+        this.baseType = this;
+    }
+
+    public Decimal64(final List<String> actualPath, final URI namespace,
+            final Date revision, final Integer fractionDigits) {
         super();
         if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
             throw new IllegalArgumentException(
@@ -67,12 +82,13 @@ public class Decimal64 implements DecimalTypeDefinition {
         }
         this.fractionDigits = fractionDigits;
         rangeStatements = defaultRangeStatements();
-        this.path = BaseTypes.schemaPath(name);
+        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.baseType = new Decimal64(fractionDigits);
     }
 
     /**
      * Decimal64 Type Constructor. <br>
-     * 
+     *
      * If parameter <code>Range Statements</code> is <code>null</code> or
      * defined as <code>empty List</code> the constructor automatically assigns
      * the boundaries as min and max value defined for Decimal64 in <a
@@ -83,14 +99,18 @@ public class Decimal64 implements DecimalTypeDefinition {
      * inclusively as defined interface {@link DecimalTypeDefinition} <br>
      * If the fraction digits are not defined inner the definition boundaries
      * the constructor will throw {@link IllegalArgumentException}
-     * 
+     *
+     * @param actualPath
+     * @param namespace
+     * @param revision
      * @param rangeStatements
      *            Range Constraint Statements
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
      * @exception IllegalArgumentException
      */
-    public Decimal64(final List<RangeConstraint> rangeStatements,
+    public Decimal64(final List<String> actualPath, final URI namespace,
+            final Date revision, final List<RangeConstraint> rangeStatements,
             Integer fractionDigits) {
         super();
         if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
@@ -100,10 +120,12 @@ public class Decimal64 implements DecimalTypeDefinition {
         if (rangeStatements == null || rangeStatements.isEmpty()) {
             this.rangeStatements = defaultRangeStatements();
         } else {
-            this.rangeStatements = Collections.unmodifiableList(rangeStatements);
+            this.rangeStatements = Collections
+                    .unmodifiableList(rangeStatements);
         }
         this.fractionDigits = fractionDigits;
-        this.path = BaseTypes.schemaPath(name);
+        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.baseType = new Decimal64(fractionDigits);
     }
 
     /**
@@ -118,7 +140,10 @@ public class Decimal64 implements DecimalTypeDefinition {
      * inclusively as defined interface {@link DecimalTypeDefinition} <br>
      * If the fraction digits are not defined inner the definition boundaries
      * the constructor will throw {@link IllegalArgumentException}
-     * 
+     *
+     * @param actualPath
+     * @param namespace
+     * @param revision
      * @param units
      *            units associated with the type
      * @param defaultValue
@@ -127,10 +152,10 @@ public class Decimal64 implements DecimalTypeDefinition {
      *            Range Constraint Statements
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
-     * 
-     * @exception IllegalArgumentException
      */
-    public Decimal64(final String units, final BigDecimal defaultValue,
+    public Decimal64(final List<String> actualPath, final URI namespace,
+            final Date revision, final String units,
+            final BigDecimal defaultValue,
             final List<RangeConstraint> rangeStatements,
             final Integer fractionDigits) {
         super();
@@ -141,19 +166,21 @@ public class Decimal64 implements DecimalTypeDefinition {
 
         if (rangeStatements == null || rangeStatements.isEmpty()) {
             this.rangeStatements = defaultRangeStatements();
-            
+
         } else {
-            this.rangeStatements = Collections.unmodifiableList(rangeStatements);
+            this.rangeStatements = Collections
+                    .unmodifiableList(rangeStatements);
         }
         this.units = units;
         this.defaultValue = defaultValue;
         this.fractionDigits = fractionDigits;
         this.path = BaseTypes.schemaPath(name);
+        this.baseType = new Decimal64(fractionDigits);
     }
 
     /**
      * Returns unmodifiable List with default definition of Range Statements.
-     * 
+     *
      * @return unmodifiable List with default definition of Range Statements.
      */
     private List<RangeConstraint> defaultRangeStatements() {
@@ -170,7 +197,7 @@ public class Decimal64 implements DecimalTypeDefinition {
 
     @Override
     public DecimalTypeDefinition getBaseType() {
-        return this;
+        return baseType;
     }
 
     @Override