List of utility methods to do BigDecimal Value Check
boolean | isAbsBetweenZeroAndOne(BigDecimal newValue) is Abs Between Zero And One BigDecimal newValueAbs = newValue.abs(); if (newValueAbs.compareTo(BigDecimal.ZERO) >= 0) { if (newValueAbs.compareTo(BigDecimal.ONE) <= 0) { return true; return false; |
boolean | isAllBlank(BigDecimal[] values) is All Blank boolean and = true; for (BigDecimal value : values) { and = and && isBlank(value); return and; |
boolean | isBetweenAAndB(final BigDecimal target, final BigDecimal a, final BigDecimal b) is Between A And B return !(target.compareTo(a) < 0 || target.compareTo(b) > 0);
|
boolean | isBlank(BigDecimal value) is Blank return (value == null || value.signum() == 0);
|
boolean | isDivisible(BigDecimal num1, BigDecimal num2) is Divisible BigDecimal result = remainder(num1, num2);
return result.compareTo(BigDecimal.ZERO) == 0 ? true : false;
|
boolean | isDouble(BigDecimal number) is Double double doubleValue = number.doubleValue(); return (doubleValue != Double.NEGATIVE_INFINITY) && (doubleValue != Double.POSITIVE_INFINITY); |
boolean | isDoubleOverFlow(final BigDecimal decimal) is Double Over Flow if (decimal.signum() == 0) { return false; BigDecimal newDecimal = decimal; boolean isPositive = decimal.signum() == 1; if (!isPositive) { newDecimal = decimal.negate(); return (newDecimal.compareTo(MIN_DOUBLE_POSITIVE) < 0 || newDecimal.compareTo(MAX_DOUBLE_POSITIVE) > 0); |
boolean | isExact(final BigDecimal bd) is Exact return bd.signum() == 0 || bd.scale() <= 0 || bd.stripTrailingZeros().scale() <= 0;
|
boolean | isFirstBiggerThanSecond(final BigDecimal first, final BigDecimal second) is First Bigger Than Second if (first == null && second == null) { return false; } else if (second == null) { return true; } else if (first == null) { return false; return first.compareTo(second) > 0; ... |
boolean | isFirstEqualToSecond(final BigDecimal first, final BigDecimal second) is First Equal To Second if (first == null && second == null) { return false; } else if (second == null) { return false; } else if (first == null) { return false; return first.compareTo(second) == 0; ... |