Skip to content

Commit

Permalink
Change predicate names isPositiveXYZ -> isNonZeroXYZ
Browse files Browse the repository at this point in the history
Resolves issue found during bisq-network#4672
review, and mentioned in comment
bisq-network#4672 (comment)
  • Loading branch information
ghubstan committed Oct 21, 2020
1 parent ac8ed8d commit 2ae6bfa
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
protected boolean allowAmountUpdate = true;
private final TradeStatisticsManager tradeStatisticsManager;

private final Predicate<ObjectProperty<Coin>> isPositiveAmount = (c) -> c.get() != null && !c.get().isZero();
private final Predicate<ObjectProperty<Price>> isPositivePrice = (p) -> p.get() != null && !p.get().isZero();
private final Predicate<ObjectProperty<Volume>> isPositiveVolume = (v) -> v.get() != null && !v.get().isZero();
private final Predicate<ObjectProperty<Coin>> isNonZeroAmount = (c) -> c.get() != null && !c.get().isZero();
private final Predicate<ObjectProperty<Price>> isNonZeroPrice = (p) -> p.get() != null && !p.get().isZero();
private final Predicate<ObjectProperty<Volume>> isNonZeroVolume = (v) -> v.get() != null && !v.get().isZero();

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, lifecycle
Expand Down Expand Up @@ -517,7 +517,7 @@ long getMaxTradeLimit() {
}

void calculateVolume() {
if (isPositivePrice.test(price) && isPositiveAmount.test(amount)) {
if (isNonZeroPrice.test(price) && isNonZeroAmount.test(amount)) {
try {
Volume volumeByAmount = calculateVolumeForAmount(amount);

Expand All @@ -533,7 +533,7 @@ void calculateVolume() {
}

void calculateMinVolume() {
if (isPositivePrice.test(price) && isPositiveAmount.test(minAmount)) {
if (isNonZeroPrice.test(price) && isNonZeroAmount.test(minAmount)) {
try {
Volume volumeByAmount = calculateVolumeForAmount(minAmount);

Expand All @@ -557,7 +557,7 @@ else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
}

void calculateAmount() {
if (isPositivePrice.test(price) && isPositiveVolume.test(volume) && allowAmountUpdate) {
if (isNonZeroPrice.test(price) && isNonZeroVolume.test(volume) && allowAmountUpdate) {
try {
Coin value = DisplayUtils.reduceTo4Decimals(price.get().getAmountByVolume(volume.get()), btcFormatter);
if (paymentAccount.isHalCashAccount())
Expand Down

0 comments on commit 2ae6bfa

Please sign in to comment.