Fixing sonar issues 4
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / Decimal64.java
index cfc39994799edd9e9088bc083ff359cd3b623467..64f1dc6e8ec49912b8eed68987200cc77897c615 100644 (file)
@@ -21,26 +21,27 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 
 /**
  * The <code>default</code> implementation of Decimal Type Definition interface.
- *
- *
+ * 
+ * 
  * @see DecimalTypeDefinition
  */
 public final class Decimal64 implements DecimalTypeDefinition {
     private final QName name = BaseTypes.constructQName("decimal64");
     private final SchemaPath path;
-    private final String units = "";
-    private final BigDecimal defaultValue = null;
+    private static final String UNITS = "";
+    private static final BigDecimal DEFAULT_VALUE = null;
 
     private final String description = "The decimal64 type represents a subset of the real numbers, which can "
             + "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can "
             + "be obtained by multiplying a 64-bit signed integer by a negative power of ten, i.e., expressible as "
             + "'i x 10^-n' where i is an integer64 and n is an integer between 1 and 18, inclusively.";
 
-    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.3";
+    private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.3";
 
     private final List<RangeConstraint> rangeStatements;
     private final Integer fractionDigits;
     private final DecimalTypeDefinition baseType;
+    private static final int MAX_NUMBER_OF_FRACTION_DIGITS = 18;
 
     /**
      * Default Decimal64 Type Constructor. <br>
@@ -48,20 +49,21 @@ public final class Decimal64 implements DecimalTypeDefinition {
      * The initial range statements are set to Decimal64
      * <code>min=-922337203685477580.8</code> and
      * <code>max=922337203685477580.7</code> <br>
-     * The fractions digits MUST be defined as integer between 1 and 18
-     * inclusively as defined interface {@link DecimalTypeDefinition} <br>
+     * The fractions digits MUST be defined as integer between 1 and
+     * {@link #MAX_NUMBER_OF_FRACTION_DIGITS} 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 path
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
-     *
+     * 
      * @see DecimalTypeDefinition
      * @exception IllegalArgumentException
      */
     public Decimal64(final SchemaPath path, final Integer fractionDigits) {
-        if (!((fractionDigits.intValue() >= 1) && (fractionDigits.intValue() <= 18))) {
+        if (!((fractionDigits.intValue() >= 1) && (fractionDigits.intValue() <= MAX_NUMBER_OF_FRACTION_DIGITS))) {
             throw new IllegalArgumentException(
                     "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
         }
@@ -73,19 +75,17 @@ public final class Decimal64 implements DecimalTypeDefinition {
 
     /**
      * Returns unmodifiable List with default definition of Range Statements.
-     *
+     * 
      * @return unmodifiable List with default definition of Range Statements.
      */
     private List<RangeConstraint> defaultRangeStatements() {
-        final List<RangeConstraint> rangeStatements = new ArrayList<RangeConstraint>();
+        final List<RangeConstraint> rangeStmts = new ArrayList<RangeConstraint>();
         final BigDecimal min = new BigDecimal("-922337203685477580.8");
         final BigDecimal max = new BigDecimal("922337203685477580.7");
-        final String rangeDescription = "Integer values between " + min
-                + " and " + max + ", inclusively.";
-        rangeStatements.add(BaseConstraints.rangeConstraint(min, max,
-                rangeDescription,
+        final String rangeDescription = "Integer values between " + min + " and " + max + ", inclusively.";
+        rangeStmts.add(BaseConstraints.rangeConstraint(min, max, rangeDescription,
                 "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
-        return Collections.unmodifiableList(rangeStatements);
+        return Collections.unmodifiableList(rangeStmts);
     }
 
     @Override
@@ -95,12 +95,12 @@ public final class Decimal64 implements DecimalTypeDefinition {
 
     @Override
     public String getUnits() {
-        return units;
+        return UNITS;
     }
 
     @Override
     public Object getDefaultValue() {
-        return defaultValue;
+        return DEFAULT_VALUE;
     }
 
     @Override
@@ -120,7 +120,7 @@ public final class Decimal64 implements DecimalTypeDefinition {
 
     @Override
     public String getReference() {
-        return reference;
+        return REFERENCE;
     }
 
     @Override
@@ -183,7 +183,6 @@ public final class Decimal64 implements DecimalTypeDefinition {
 
     @Override
     public String toString() {
-        return Decimal64.class.getSimpleName() + "[qname=" + name
-                + ", fractionDigits=" + fractionDigits + "]";
+        return Decimal64.class.getSimpleName() + "[qname=" + name + ", fractionDigits=" + fractionDigits + "]";
     }
 }