Source:
public PaymentAccount addPaymentAccount(PaymentAccount paymentAccount) { if (paymentAccount instanceof CryptoCurrencyAccount) { CryptoCurrencyAccount cryptoCurrencyAccount = (CryptoCurrencyAccount) paymentAccount; TradeCurrency tradeCurrency = cryptoCurrencyAccount.getSingleTradeCurrency(); if (tradeCurrency == null) { throw new ValidationException("CryptoCurrency account must have exactly one trade currency"); } altCoinAddressValidator.setCurrencyCode(tradeCurrency.getCode()); InputValidator.ValidationResult validationResult = altCoinAddressValidator.validate(cryptoCurrencyAccount.getAddress()); if (!validationResult.isValid) { throw new ValidationException(validationResult.errorMessage); } } user.addPaymentAccount(paymentAccount); TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency(); List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies(); if (singleTradeCurrency != null) { if (singleTradeCurrency instanceof FiatCurrency) preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency); else preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency); } else if (!tradeCurrencies.isEmpty()) { tradeCurrencies.forEach(tradeCurrency -> { if (tradeCurrency instanceof FiatCurrency) preferences.addFiatCurrency((FiatCurrency) tradeCurrency); else preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency); }); } if (!(paymentAccount instanceof CryptoCurrencyAccount)) { if (singleTradeCurrency == null && !tradeCurrencies.isEmpty()) { if (tradeCurrencies.contains(CurrencyUtil.getDefaultTradeCurrency())) paymentAccount.setSelectedTradeCurrency(CurrencyUtil.getDefaultTradeCurrency()); else paymentAccount.setSelectedTradeCurrency(tradeCurrencies.get(0)); } accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload()); } return paymentAccount; }

Target:
public PaymentAccount addPaymentAccount(PaymentAccount paymentAccount) { if (paymentAccount instanceof CryptoCurrencyAccount) { CryptoCurrencyAccount cryptoCurrencyAccount = (CryptoCurrencyAccount) paymentAccount; TradeCurrency tradeCurrency = cryptoCurrencyAccount.getSingleTradeCurrency(); if (tradeCurrency == null) { throw new ValidationException("CryptoCurrency account must have exactly one trade currency"); } altCoinAddressValidator.setCurrencyCode(tradeCurrency.getCode()); InputValidator.ValidationResult validationResult = altCoinAddressValidator.validate(cryptoCurrencyAccount.getAddress()); if (!validationResult.isValid) { throw new ValidationException(validationResult.errorMessage); } } TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency(); List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies(); if (singleTradeCurrency != null) { if (singleTradeCurrency instanceof FiatCurrency) preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency); else preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency); } else if (!tradeCurrencies.isEmpty()) { tradeCurrencies.forEach(tradeCurrency -> { if (tradeCurrency instanceof FiatCurrency) preferences.addFiatCurrency((FiatCurrency) tradeCurrency); else preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency); }); } user.addPaymentAccount(paymentAccount); if (!(paymentAccount instanceof CryptoCurrencyAccount)) { if (singleTradeCurrency == null && !tradeCurrencies.isEmpty()) { if (tradeCurrencies.contains(CurrencyUtil.getDefaultTradeCurrency())) paymentAccount.setSelectedTradeCurrency(CurrencyUtil.getDefaultTradeCurrency()); else paymentAccount.setSelectedTradeCurrency(tradeCurrencies.get(0)); } accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload()); } return paymentAccount; }