Package com.ocs.dynamo.utils
Class MathUtils
- java.lang.Object
-
- com.ocs.dynamo.utils.MathUtils
-
public final class MathUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static BigDecimalHUNDRED
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigDecimaldividePercentage(Integer first, Integer second, int scale)Divides the first argument by the second argument, then converts to a percentagestatic BigDecimaldividePercentage(BigDecimal first, BigDecimal second, int scale)Divides the first argument by the second argument, then converts the result to a percentagestatic BigDecimalmultiplyPercentage(BigDecimal percentage, BigDecimal value, int scale)Returns the result of multiplying a value with a certain percentage, rounded to the specified precisionstatic intnullSafeGet(Integer x)Performs a null-safe get of an Integerstatic longnullSafeGet(Long x)
-
-
-
Field Detail
-
HUNDRED
public static final BigDecimal HUNDRED
-
-
Method Detail
-
dividePercentage
public static BigDecimal dividePercentage(BigDecimal first, BigDecimal second, int scale)
Divides the first argument by the second argument, then converts the result to a percentage- Parameters:
first- the first argumentsecond- the second argumentscale-- Returns:
-
dividePercentage
public static BigDecimal dividePercentage(Integer first, Integer second, int scale)
Divides the first argument by the second argument, then converts to a percentage- Parameters:
first- the first argumentsecond- the second argumentscale- the desired scale- Returns:
-
multiplyPercentage
public static BigDecimal multiplyPercentage(BigDecimal percentage, BigDecimal value, int scale)
Returns the result of multiplying a value with a certain percentage, rounded to the specified precision- Parameters:
percentage- the percentage valuevalue- the non-percentage valuescale- the scale- Returns:
-
nullSafeGet
public static int nullSafeGet(Integer x)
Performs a null-safe get of an Integer- Parameters:
x- the integer- Returns:
-
nullSafeGet
public static long nullSafeGet(Long x)
-
-