← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17336: Added util method

 

------------------------------------------------------------
revno: 17336
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-11-02 17:01:27 -0500
message:
  Added util method
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java	2014-09-19 13:35:52 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java	2014-11-02 22:01:27 +0000
@@ -173,7 +173,7 @@
     }
     
     /**
-     * Return a rounded off number.
+     * Returns a rounded off number.
      * 
      * <ul>
      * <li>If value is exclusively between 1 and -1 it will have 2 decimals.</li>
@@ -196,6 +196,17 @@
     }
 
     /**
+     * Returns a rounded off number. If the value class is not Double, the value
+     * is returned unchanged.
+     * 
+     * @param value the value to return and potentially round off.
+     */
+    public static Object getRounded( Object value )
+    {
+        return value != null && Double.class.equals( value.getClass() ) ? getRounded( (Double) value ) : value;
+    }
+
+    /**
      * Rounds a number, keeping at least 3 significant digits.
      * 
      * <ul>