Checking whether an amount is zero, negative, or positive is quite a common usage scenario and adding helper methods would make this check much easier.
Currently we have to create a zero object and compare the actual value with this.
JavaMoney has some great comparators, like .isZero(), isZeroOrNegative(), etc. (https://github.com/JavaMoney/jsr354-ri/blob/master/src/main/java/org/javamoney/moneta/FastMoney.java)
Would be great if Money type had something similar built in.
i.e.
@Override
public boolean isZero() {
return this.number == 0L;
}
@Override
public boolean isPositive() {
return this.number > 0L;
}
@Override
public boolean isPositiveOrZero() {
return this.number >= 0L;
}
@Override
public boolean isNegative() {
return this.number < 0L;
}
@Override
public boolean isNegativeOrZero() {
return this.number <= 0L;
}
Hi,
Checking whether an amount is zero, negative, or positive is quite a common usage scenario and adding helper methods would make this check much easier. Currently we have to create a zero object and compare the actual value with this. JavaMoney has some great comparators, like .isZero(), isZeroOrNegative(), etc. (https://github.com/JavaMoney/jsr354-ri/blob/master/src/main/java/org/javamoney/moneta/FastMoney.java) Would be great if Money type had something similar built in.
i.e.
BigDecimal implementation is using .signum(). https://github.com/JavaMoney/jsr354-ri/blob/master/src/main/java/org/javamoney/moneta/Money.java