mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Tidy up CorePriceService
Remove unnecessary String.format call and do a null check.
This commit is contained in:
parent
f051a03d29
commit
0cc998c4e2
1 changed files with 5 additions and 5 deletions
|
@ -20,13 +20,13 @@ package bisq.core.api;
|
|||
import bisq.core.provider.price.MarketPrice;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
|
||||
import bisq.common.util.MathUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static bisq.common.util.MathUtils.roundDouble;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
|
||||
@Slf4j
|
||||
|
@ -41,11 +41,11 @@ class CorePriceService {
|
|||
|
||||
public double getMarketPrice(String currencyCode) {
|
||||
if (!priceFeedService.hasPrices())
|
||||
throw new IllegalStateException(format("price feed service has no prices"));
|
||||
throw new IllegalStateException("price feed service has no prices");
|
||||
|
||||
MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode.toUpperCase());
|
||||
if (marketPrice.isPriceAvailable()) {
|
||||
return MathUtils.roundDouble(marketPrice.getPrice(), 4);
|
||||
if (requireNonNull(marketPrice).isPriceAvailable()) {
|
||||
return roundDouble(marketPrice.getPrice(), 4);
|
||||
} else {
|
||||
throw new IllegalStateException(format("'%s' price is not available", currencyCode));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue