replace BigInteger.valueOf(0) with BigInteger.ZERO

This commit is contained in:
woodser 2023-12-08 07:45:22 -05:00
parent cd89b8bf15
commit 3730773006
34 changed files with 81 additions and 81 deletions

View file

@ -151,9 +151,9 @@ public class AddressTextField extends AnchorPane {
///////////////////////////////////////////////////////////////////////////////////////////
private String getMoneroURI() {
if (amount.get().compareTo(BigInteger.valueOf(0)) < 0) {
if (amount.get().compareTo(BigInteger.ZERO) < 0) {
log.warn("Amount must not be negative");
setAmount(BigInteger.valueOf(0));
setAmount(BigInteger.ZERO);
}
return GUIUtil.getMoneroURI(
address.get(),

View file

@ -53,7 +53,7 @@ class TransactionsListItem {
private String direction = "";
private boolean received;
private boolean detailsAvailable;
private BigInteger amount = BigInteger.valueOf(0);
private BigInteger amount = BigInteger.ZERO;
private String memo = "";
private long confirmations = 0;
@Getter
@ -88,8 +88,8 @@ class TransactionsListItem {
Optional<Tradable> optionalTradable = Optional.ofNullable(transactionAwareTradable)
.map(TransactionAwareTradable::asTradable);
BigInteger valueSentToMe = tx.getIncomingAmount() == null ? BigInteger.valueOf(0) : tx.getIncomingAmount();
BigInteger valueSentFromMe = tx.getOutgoingAmount() == null ? BigInteger.valueOf(0) : tx.getOutgoingAmount();
BigInteger valueSentToMe = tx.getIncomingAmount() == null ? BigInteger.ZERO : tx.getIncomingAmount();
BigInteger valueSentFromMe = tx.getOutgoingAmount() == null ? BigInteger.ZERO : tx.getOutgoingAmount();
if (tx.getTransfers().get(0).isIncoming()) {
addressString = ((MoneroIncomingTransfer) tx.getTransfers().get(0)).getAddress();
@ -99,7 +99,7 @@ class TransactionsListItem {
else addressString = "unavailable";
}
if (valueSentFromMe.compareTo(BigInteger.valueOf(0)) == 0) {
if (valueSentFromMe.compareTo(BigInteger.ZERO) == 0) {
amount = valueSentToMe;
direction = Res.get("funds.tx.direction.receivedWith");
received = true;
@ -125,13 +125,13 @@ class TransactionsListItem {
} else if (trade.getPayoutTxId() != null &&
trade.getPayoutTxId().equals(txId)) {
details = Res.get("funds.tx.multiSigPayout", tradeId);
if (amount.compareTo(BigInteger.valueOf(0)) == 0) {
if (amount.compareTo(BigInteger.ZERO) == 0) {
initialTxConfidenceVisibility = false;
}
} else {
Trade.DisputeState disputeState = trade.getDisputeState();
if (disputeState == Trade.DisputeState.DISPUTE_CLOSED) {
if (valueSentToMe.compareTo(BigInteger.valueOf(0)) > 0) {
if (valueSentToMe.compareTo(BigInteger.ZERO) > 0) {
details = Res.get("funds.tx.disputePayout", tradeId);
} else {
details = Res.get("funds.tx.disputeLost", tradeId);
@ -139,7 +139,7 @@ class TransactionsListItem {
} else if (disputeState == Trade.DisputeState.REFUND_REQUEST_CLOSED ||
disputeState == Trade.DisputeState.REFUND_REQUESTED ||
disputeState == Trade.DisputeState.REFUND_REQUEST_STARTED_BY_PEER) {
if (valueSentToMe.compareTo(BigInteger.valueOf(0)) > 0) {
if (valueSentToMe.compareTo(BigInteger.ZERO) > 0) {
details = Res.get("funds.tx.refund", tradeId);
} else {
// We have spent the deposit tx outputs to the Haveno donation address to enable
@ -147,7 +147,7 @@ class TransactionsListItem {
// already when funding the deposit tx we show 0 BTC as amount.
// Confirmation is not known from the BitcoinJ side (not 100% clear why) as no funds
// left our wallet nor we received funds. So we set indicator invisible.
amount = BigInteger.valueOf(0);
amount = BigInteger.ZERO;
details = Res.get("funds.tx.collateralForRefund", tradeId);
initialTxConfidenceVisibility = false;
}
@ -157,7 +157,7 @@ class TransactionsListItem {
}
}
} else {
if (amount.compareTo(BigInteger.valueOf(0)) == 0) {
if (amount.compareTo(BigInteger.ZERO) == 0) {
details = Res.get("funds.tx.noFundsFromDispute");
}
}

View file

@ -75,7 +75,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
private final P2PService p2PService;
private final WalletPasswordWindow walletPasswordWindow;
private XmrBalanceListener balanceListener;
private BigInteger amount = BigInteger.valueOf(0);
private BigInteger amount = BigInteger.ZERO;
private ChangeListener<String> amountListener;
private ChangeListener<Boolean> amountFocusListener;
private ChangeListener<Toggle> feeToggleGroupListener;
@ -148,7 +148,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
};
amountFocusListener = (observable, oldValue, newValue) -> {
if (oldValue && !newValue) {
if (amount.compareTo(BigInteger.valueOf(0)) > 0)
if (amount.compareTo(BigInteger.ZERO) > 0)
amountTextField.setText(HavenoUtils.formatXmr(amount));
else
amountTextField.setText("");
@ -200,7 +200,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
final String withdrawToAddress = withdrawToTextField.getText();
// create tx
if (amount.compareTo(BigInteger.valueOf(0)) <= 0) throw new RuntimeException(Res.get("portfolio.pending.step5_buyer.amountTooLow"));
if (amount.compareTo(BigInteger.ZERO) <= 0) throw new RuntimeException(Res.get("portfolio.pending.step5_buyer.amountTooLow"));
MoneroTxWallet tx = xmrWalletService.getWallet().createTx(new MoneroTxConfig()
.setAccountIndex(0)
.setAmount(amount)
@ -262,7 +262,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
.filter(Trade::isPayoutPublished)
.forEach(trade -> xmrWalletService.getAddressEntry(trade.getId(), XmrAddressEntry.Context.TRADE_PAYOUT)
.ifPresent(addressEntry -> {
if (xmrWalletService.getBalanceForAddress(addressEntry.getAddressString()).compareTo(BigInteger.valueOf(0)) == 0)
if (xmrWalletService.getBalanceForAddress(addressEntry.getAddressString()).compareTo(BigInteger.ZERO) == 0)
tradeManager.onTradeCompleted(trade);
}));
} catch (Exception e) {
@ -276,7 +276,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
///////////////////////////////////////////////////////////////////////////////////////////
private void reset() {
amount = BigInteger.valueOf(0);
amount = BigInteger.ZERO;
amountTextField.setText("");
amountTextField.setPromptText(Res.get("funds.withdrawal.setAmount"));

View file

@ -123,7 +123,7 @@ public class SpreadView extends ActivatableViewAndModel<GridPane, SpreadViewMode
int numberOfBuyOffers = sortedList.stream().mapToInt(item -> item.numberOfBuyOffers).sum();
int numberOfSellOffers = sortedList.stream().mapToInt(item -> item.numberOfSellOffers).sum();
BigInteger totalAmount = BigInteger.valueOf(0);
BigInteger totalAmount = BigInteger.ZERO;
for (SpreadItem item : sortedList) totalAmount = totalAmount.add(item.totalAmount);
String total = HavenoUtils.formatXmr(totalAmount);

View file

@ -129,7 +129,7 @@ class SpreadViewModel extends ActivatableViewModel {
}
spreadItems.clear();
BigInteger totalAmount = BigInteger.valueOf(0);
BigInteger totalAmount = BigInteger.ZERO;
for (String key : offersByCurrencyMap.keySet()) {
List<Offer> offers = offersByCurrencyMap.get(key);

View file

@ -121,7 +121,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
protected boolean allowAmountUpdate = true;
private final TradeStatisticsManager tradeStatisticsManager;
private final Predicate<ObjectProperty<BigInteger>> isNonZeroAmount = (c) -> c.get() != null && c.get().compareTo(BigInteger.valueOf(0)) != 0;
private final Predicate<ObjectProperty<BigInteger>> isNonZeroAmount = (c) -> c.get() != null && c.get().compareTo(BigInteger.ZERO) != 0;
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();
@Getter
@ -642,7 +642,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
private BigInteger getSellerSecurityDeposit() {
BigInteger amount = this.amount.get();
if (amount == null)
amount = BigInteger.valueOf(0);
amount = BigInteger.ZERO;
BigInteger percentOfAmount = CoinUtil.getPercentOfAmount(
createOfferService.getSellerSecurityDepositAsDouble(buyerSecurityDepositPct.get()), amount);

View file

@ -330,7 +330,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
// called from parent as the view does not get notified when the tab is closed
public void onClose() {
// we use model.placeOfferCompleted to not react on close which was triggered by a successful placeOffer
if (model.getDataModel().getBalance().get().compareTo(BigInteger.valueOf(0)) > 0 && !model.placeOfferCompleted.get()) {
if (model.getDataModel().getBalance().get().compareTo(BigInteger.ZERO) > 0 && !model.placeOfferCompleted.get()) {
model.getDataModel().swapTradeToSavings();
}
}

View file

@ -49,7 +49,7 @@ public abstract class OfferDataModel extends ActivatableDataModel {
@Getter
protected final ObjectProperty<BigInteger> availableBalance = new SimpleObjectProperty<>();
@Getter
protected final ObjectProperty<BigInteger> missingCoin = new SimpleObjectProperty<>(BigInteger.valueOf(0));
protected final ObjectProperty<BigInteger> missingCoin = new SimpleObjectProperty<>(BigInteger.ZERO);
@Getter
protected final BooleanProperty showWalletFundedNotification = new SimpleBooleanProperty();
@Getter

View file

@ -353,7 +353,7 @@ class TakeOfferDataModel extends OfferDataModel {
void calculateVolume() {
if (tradePrice != null && offer != null &&
amount.get() != null &&
amount.get().compareTo(BigInteger.valueOf(0)) != 0) {
amount.get().compareTo(BigInteger.ZERO) != 0) {
Volume volumeByAmount = tradePrice.getVolumeByAmount(amount.get());
volumeByAmount = VolumeUtil.getAdjustedVolume(volumeByAmount, offer.getPaymentMethod().getId());

View file

@ -360,7 +360,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
// Called from parent as the view does not get notified when the tab is closed
public void onClose() {
BigInteger availableBalance = model.dataModel.getAvailableBalance().get();
if (availableBalance != null && availableBalance.compareTo(BigInteger.valueOf(0)) > 0 && !model.takeOfferCompleted.get() && !DevEnv.isDevMode()) {
if (availableBalance != null && availableBalance.compareTo(BigInteger.ZERO) > 0 && !model.takeOfferCompleted.get() && !DevEnv.isDevMode()) {
model.dataModel.swapTradeToSavings();
}
}

View file

@ -364,7 +364,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
// be made
return totalAmount.compareTo(available) <= 0;
} else {
if (totalAmount.compareTo(BigInteger.valueOf(0)) <= 0) {
if (totalAmount.compareTo(BigInteger.ZERO) <= 0) {
return false;
}
return totalAmount.compareTo(available) == 0;
@ -612,23 +612,23 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
String sellerPayoutAddressString = contract.getSellerPayoutAddressString();
List<MoneroDestination> destinations = payoutTx.getOutgoingTransfer().getDestinations();
boolean buyerFirst = destinations.get(0).getAddress().equals(buyerPayoutAddressString);
BigInteger buyerPayoutAmount = buyerFirst ? destinations.get(0).getAmount() : destinations.size() == 2 ? destinations.get(1).getAmount() : BigInteger.valueOf(0);
BigInteger sellerPayoutAmount = buyerFirst ? (destinations.size() == 2 ? destinations.get(1).getAmount() : BigInteger.valueOf(0)) : destinations.get(0).getAmount();
BigInteger buyerPayoutAmount = buyerFirst ? destinations.get(0).getAmount() : destinations.size() == 2 ? destinations.get(1).getAmount() : BigInteger.ZERO;
BigInteger sellerPayoutAmount = buyerFirst ? (destinations.size() == 2 ? destinations.get(1).getAmount() : BigInteger.ZERO) : destinations.get(0).getAmount();
String buyerDetails = "";
if (buyerPayoutAmount.compareTo(BigInteger.valueOf(0)) > 0) {
if (buyerPayoutAmount.compareTo(BigInteger.ZERO) > 0) {
buyerDetails = Res.get("disputeSummaryWindow.close.txDetails.buyer",
HavenoUtils.formatXmr(buyerPayoutAmount, true),
buyerPayoutAddressString);
}
String sellerDetails = "";
if (sellerPayoutAmount.compareTo(BigInteger.valueOf(0)) > 0) {
if (sellerPayoutAmount.compareTo(BigInteger.ZERO) > 0) {
sellerDetails = Res.get("disputeSummaryWindow.close.txDetails.seller",
HavenoUtils.formatXmr(sellerPayoutAmount, true),
sellerPayoutAddressString);
}
BigInteger outputAmount = buyerPayoutAmount.add(sellerPayoutAmount).add(payoutTx.getFee());
if (outputAmount.compareTo(BigInteger.valueOf(0)) > 0) {
if (outputAmount.compareTo(BigInteger.ZERO) > 0) {
new Popup().width(900)
.headLine(Res.get("disputeSummaryWindow.close.txDetails.headline"))
.confirmation(Res.get("disputeSummaryWindow.close.txDetails",
@ -728,13 +728,13 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
sellerPayoutAmount.equals(sellerSecurityDeposit)) {
buyerGetsTradeAmountRadioButton.setSelected(true);
} else if (buyerPayoutAmount.equals(tradeAmount.add(buyerSecurityDeposit).add(sellerSecurityDeposit)) &&
sellerPayoutAmount.equals(BigInteger.valueOf(0))) {
sellerPayoutAmount.equals(BigInteger.ZERO)) {
buyerGetsAllRadioButton.setSelected(true);
} else if (sellerPayoutAmount.equals(tradeAmount.add(sellerSecurityDeposit))
&& buyerPayoutAmount.equals(buyerSecurityDeposit)) {
sellerGetsTradeAmountRadioButton.setSelected(true);
} else if (sellerPayoutAmount.equals(tradeAmount.add(buyerSecurityDeposit).add(sellerSecurityDeposit))
&& buyerPayoutAmount.equals(BigInteger.valueOf(0))) {
&& buyerPayoutAmount.equals(BigInteger.ZERO)) {
sellerGetsAllRadioButton.setSelected(true);
} else {
customRadioButton.setSelected(true);

View file

@ -276,14 +276,14 @@ public class PendingTradesDataModel extends ActivatableDataModel {
return offer.getMakerFee();
} else {
log.error("offer is null");
return BigInteger.valueOf(0);
return BigInteger.ZERO;
}
} else {
return trade.getTakerFee();
}
} else {
log.error("Trade is null at getTotalFees");
return BigInteger.valueOf(0);
return BigInteger.ZERO;
}
}