Class MathUtils


  • public final class MathUtils
    extends Object
    • Field Detail

    • 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 argument
        second - the second argument
        scale -
        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 argument
        second - the second argument
        scale - 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 value
        value - the non-percentage value
        scale - 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)