Populate SwiftAccount tradeCurrencies field inside constructor

The API uses reflection to figure out how to build a payment acct json
form, and the tradeCurrencies field needs to be set after reflection
API's onstructor.newInstance() is called.
This commit is contained in:
ghubstan 2021-11-22 12:02:17 -03:00
parent a113b3ddfb
commit 1fcb751d8c
No known key found for this signature in database
GPG key ID: E35592D6800A861E
2 changed files with 9 additions and 9 deletions

View file

@ -20,9 +20,9 @@ package bisq.core.payment;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.FiatCurrency;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.payload.SwiftAccountPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.payment.payload.SwiftAccountPayload;
import java.util.Comparator;
import java.util.List;
@ -34,6 +34,7 @@ import lombok.EqualsAndHashCode;
public final class SwiftAccount extends PaymentAccount {
public SwiftAccount() {
super(PaymentMethod.SWIFT);
selectAllTradeCurrencies();
}
@Override
@ -45,13 +46,6 @@ public final class SwiftAccount extends PaymentAccount {
return ((SwiftAccountPayload) this.paymentAccountPayload);
}
public void selectAllTradeCurrencies() {
List<FiatCurrency> currencyCodesSorted = CurrencyUtil.getAllSortedFiatCurrencies().stream()
.sorted(Comparator.comparing(TradeCurrency::getCode))
.collect(Collectors.toList());
tradeCurrencies.addAll(currencyCodesSorted);
}
public String getMessageForBuyer() {
return "payment.swift.info.buyer";
}
@ -63,4 +57,11 @@ public final class SwiftAccount extends PaymentAccount {
public String getMessageForAccountCreation() {
return "payment.swift.info.account";
}
private void selectAllTradeCurrencies() {
List<FiatCurrency> currencyCodesSorted = CurrencyUtil.getAllSortedFiatCurrencies().stream()
.sorted(Comparator.comparing(TradeCurrency::getCode))
.collect(Collectors.toList());
tradeCurrencies.addAll(currencyCodesSorted);
}
}

View file

@ -74,7 +74,6 @@ public class SwiftForm extends PaymentMethodForm {
@Override
public void addFormForAddAccount() {
((SwiftAccount) paymentAccount).selectAllTradeCurrencies();
gridRowFrom = gridRow + 1;
addFieldsForBankEdit(true, this::setBankSwiftCode, this::setBankName, this::setBankBranch, this::setBankAddress);
addFieldsForBankEdit(false, this::setIntermediarySwiftCode, this::setIntermediaryName, this::setIntermediaryBranch, this::setIntermediaryAddress);