Class BigDecimalHelper


  • public class BigDecimalHelper
    extends Object
    Helper class for handling BigDecimals.
    • Constructor Detail

      • BigDecimalHelper

        public BigDecimalHelper()
    • Method Detail

      • areEqualsOrBothNull

        public static boolean areEqualsOrBothNull​(BigDecimal bd1,
                                                  BigDecimal bd2)
      • hashCode

        public static int hashCode​(BigDecimal bd1)
      • isNegative

        public static boolean isNegative​(BigDecimal number)
        Returns whether the given number is a negative, non-zero number, given a precision delta
      • isNegativeOrZero

        public static boolean isNegativeOrZero​(BigDecimal number)
        Returns whether the given number is a negative or zero number, given a precision delta
      • isPositive

        public static boolean isPositive​(BigDecimal number)
        Returns whether the given number is a positive, non-zero number, given a precision delta
      • isPositiveOrZero

        public static boolean isPositiveOrZero​(BigDecimal number)
        Returns whether the given number is a positive or zero number, given a precision delta
      • isZero

        public static boolean isZero​(BigDecimal number)
        Returns whether the given number is a negative, non-zero number, given a precision delta
      • negative

        public static BigDecimal negative​(BigDecimal bigDecimal)
        Returns a negative representation of the given number. If null or already negative, return as is. Otherwise, returns the negated value.
      • positive

        public static BigDecimal positive​(BigDecimal bigDecimal)
        Returns a positive representation of the given number. If null or already positive, return as is. Otherwise, returns the negated value.
      • round

        public static BigDecimal round​(BigDecimal number,
                                       int scale)
        Rounds the given number to the given scale
      • toBigDecimal

        public static BigDecimal toBigDecimal​(String intPart,
                                              String decimalPart)
        Converts the given integer part and decimal part to a BigDecimal value. If either is null, returns null.
      • zeroWhenNull

        public static BigDecimal zeroWhenNull​(BigDecimal bigDecimal)
        Returns zero when the given BigDecimal is null