java.lang.Object
com.github.hypfvieh.util.NumberUtil
Helper class to convert different types of strings to double/BigDecimal.
BigDecimals are usually created with a scale of
BigDecimals are usually created with a scale of
BIGDECIMAL_DEFAULT_FRACTIONS, if not specified otherwise.-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final intstatic final BigDecimalstatic final BigDecimal -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic BigDecimalstatic BigDecimalconvertNumberToBigDecimal(Number _num, int _fractionDigits) Converts aNumberto aBigDecimalusing given fraction digits as scale.static BigDecimalinvert(BigDecimal _bd) Inverts aBigDecimal.static booleanisEqual(BigDecimal _v1, BigDecimal _v2) Compares v1 vs. v2 and will return true if they are equal.static booleanisGreater(BigDecimal _v1, BigDecimal _v2) Compares v1 vs. v2 and will return true if v1 is bigger than v2.static booleanisGreaterOrEqual(BigDecimal _v1, BigDecimal _v2) Compares v1 vs. v2 and will return true if they are equal or v1 is bigger than v2.static booleanisLess(BigDecimal _v1, BigDecimal _v2) Compares v1 vs. v2 and will return true if v1 is smaller than v2.static booleanisLessOrEqual(BigDecimal _v1, BigDecimal _v2) Compares v1 vs. v2 and will return true if they are equal or v1 is smaller than v2.static booleanisNegative(BigDecimal _bd) Checks if given BigDecimal is negative.static booleanisZero(BigDecimal _val) Checks if the given BigDecimal is zero.static BigDecimalsumBigDecimals(BigDecimal... _add) Sums the givenBigDecimals.static BigDecimalsumBigDecimals(Collection<BigDecimal> _add) Sums the given collection ofBigDecimals.
Will ignore any null value in collection.
When a null collection is given, zero is returned.
-
Felddetails
-
BIGDECIMAL_DEFAULT_FRACTIONS
public static final int BIGDECIMAL_DEFAULT_FRACTIONS- Siehe auch:
-
NEGATIVE_ONE
-
ONE_HUNDRED
-
-
Methodendetails
-
convertNumberToBigDecimal
- Parameter:
_num- number to convert- Gibt zurück:
- BigDecimal or null if input was null
-
convertNumberToBigDecimal
Converts aNumberto aBigDecimalusing given fraction digits as scale.- Parameter:
_num- number to convert- Gibt zurück:
- BigDecimal or null if input was null
-
isLess
Compares v1 vs. v2 and will return true if v1 is smaller than v2.
This comparison ignores the scale of theBigDecimal.
Will return false if any (or both) parameter is null- Parameter:
_v1- first value_v2- second value- Gibt zurück:
- true if first value smaller than second
-
isGreater
Compares v1 vs. v2 and will return true if v1 is bigger than v2.
This comparison ignores the scale of theBigDecimal.
Will return false if any (or both) parameter is null- Parameter:
_v1- first value_v2- second value- Gibt zurück:
- true if first value bigger than second
-
isEqual
Compares v1 vs. v2 and will return true if they are equal.
This comparison ignores the scale of theBigDecimal, which will be done whenBigDecimal.equals(Object)is used.
Will return false if any (or both) parameter is null- Parameter:
_v1- first value_v2- second value- Gibt zurück:
- true if equal
-
isZero
Checks if the given BigDecimal is zero. This comparison ignores the scale of theBigDecimal. Will return false if the input value is null.- Parameter:
_val- the value to check- Gibt zurück:
- true if the value is zero, false otherwise
-
isGreaterOrEqual
Compares v1 vs. v2 and will return true if they are equal or v1 is bigger than v2.
This comparison ignores the scale of theBigDecimal, which will be done whenBigDecimal.equals(Object)is used.
Will return false if any (or both) parameter is null- Parameter:
_v1- first value_v2- second value- Gibt zurück:
- true if bigger or equal
-
isLessOrEqual
Compares v1 vs. v2 and will return true if they are equal or v1 is smaller than v2.
This comparison ignores the scale of theBigDecimal, which will be done whenBigDecimal.equals(Object)is used.
Will return false if any (or both) parameter is null- Parameter:
_v1- first value_v2- second value- Gibt zurück:
- true if smaller or equal
-
isNegative
Checks if given BigDecimal is negative.- Parameter:
_bd- value- Gibt zurück:
- true if negative
-
invert
Inverts aBigDecimal. This means, if given value was negative, the positive representation is returned and vice versa.- Parameter:
_bd- value- Gibt zurück:
- inverted BigDecimal or null if input was null
-
sumBigDecimals
Sums the givenBigDecimals. Will return null if any of the given objects is null.- Parameter:
_add- var args containing BigDecimals to sum- Gibt zurück:
- BigDecimal, BigDecimal.ZERO when no or null input is given
-
sumBigDecimals
Sums the given collection ofBigDecimals.
Will ignore any null value in collection.
When a null collection is given, zero is returned.- Parameter:
_add- collection of bigdecimals- Gibt zurück:
- BigDecimal, never null
-