Skip to content

Commit

Permalink
Merge pull request #4764 from bigscoop/usertrade-builder
Browse files Browse the repository at this point in the history
[minor-refactoring] Replace explicit constructor calls with builder() method
  • Loading branch information
timmolter authored Dec 1, 2023
2 parents 410506f + 928ae88 commit 01f9aa8
Show file tree
Hide file tree
Showing 74 changed files with 102 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static UserTrades adaptUserTrades(
ascendexOrderHistoryResponse.forEach(
order ->
userTrades.add(
new UserTrade.Builder()
UserTrade.builder()
.feeAmount(order.getCumFee())
.orderId(order.getOrderId())
.price(order.getPrice())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static List<UserTrade> adaptUserTrades(BankeraUserTrades userTrades) {
CurrencyPair pair = new CurrencyPair(currencies[0], currencies[1]);
Currency feeCurrency = new Currency(currencies[1]);
tradeList.add(
new UserTrade.Builder()
UserTrade.builder()
.type(trade.getSide().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK)
.originalAmount(new BigDecimal(trade.getAmount()))
.currencyPair(pair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static UserTrades adaptUserTrades(BiboxOrders biboxOrderHistory) {
}

private static UserTrade adaptUserTrade(BiboxOrder order) {
return new UserTrade.Builder()
return UserTrade.builder()
.orderId(order.getId())
.id(order.getId())
.currencyPair(new CurrencyPair(order.getCoinSymbol(), order.getCurrencySymbol()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public static UserTrades adaptUserTrades(List<BinanceTrade> binanceTrades, boole
binanceTrades.stream()
.map(
t ->
new UserTrade.Builder()
UserTrade.builder()
.type(BinanceAdapters.convertType(t.isBuyer))
.originalAmount(t.qty)
.instrument(adaptSymbol(t.symbol, isFuture))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private static UserTrade createUserTrade(BitbayOrder bitbayOrder) {
throw new IllegalArgumentException(e);
}

return new UserTrade.Builder()
return UserTrade.builder()
.type(type)
.originalAmount(bitbayOrder.getAmount())
.currencyPair(currencyPair)
Expand Down Expand Up @@ -244,7 +244,7 @@ public static List<UserTrade> adaptTransactions(List<Map> response) {
String id = (type + "_" + date + "_" + market).replaceAll("\\s+", "");

trades.add(
new UserTrade.Builder()
UserTrade.builder()
.type(orderType)
.originalAmount(amount)
.currencyPair(pair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static UserTrades adaptUserTrades(BitbayUserTrades response) {
new CurrencyPair(Currency.getInstance(parts[0]), Currency.getInstance(parts[1]));
Date timestamp = new Date(trade.getTime());
trades.add(
new UserTrade.Builder()
UserTrade.builder()
.id(trade.getId().toString())
.type(orderType)
.originalAmount(trade.getAmount())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public static UserTrades adaptTradeHistory(
: trade.getCreatedAt();

result.add(
new UserTrade.Builder()
UserTrade.builder()
.id(trade.getTradeId())
.timestamp(timestamp)
.currencyPair(trade.getTradingPair())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ public static UserTrades adaptTradeHistory(BitfinexTradeResponse[] trades, Strin
Date timestamp = convertBigDecimalTimestampToDate(trade.getTimestamp());
final BigDecimal fee = trade.getFeeAmount() == null ? null : trade.getFeeAmount().negate();
pastTrades.add(
new UserTrade.Builder()
UserTrade.builder()
.type(orderType)
.originalAmount(trade.getAmount())
.currencyPair(currencyPair)
Expand Down Expand Up @@ -611,7 +611,7 @@ public static UserTrades adaptTradeHistoryV2(
: trade.getExecAmount();
final BigDecimal fee = trade.getFee() != null ? trade.getFee().negate() : null;
pastTrades.add(
new UserTrade.Builder()
UserTrade.builder()
.type(orderType)
.originalAmount(amount)
.currencyPair(adaptCurrencyPair(trade.getSymbol()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static UserTrades adaptUserTrades(
private static UserTrade adaptUserTrade(
BithumbUserTransaction bithumbTransaction, CurrencyPair currencyPair) {

return new UserTrade.Builder()
return UserTrade.builder()
.currencyPair(currencyPair)
.originalAmount(bithumbTransaction.getUnits())
.type(adaptTransactionSearch(bithumbTransaction.getSearch()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public static UserTrade adoptUserTrade(BitmexPrivateExecution exec) {
OrderType orderType = convertType(exec.side);
return orderType == null
? null
: new UserTrade.Builder()
: UserTrade.builder()
.id(exec.execID)
.orderId(exec.orderID)
.currencyPair(pair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static UserTrades adaptTradeHistory(BitsoUserTransaction[] bitsoUserTrans
String feeCurrency =
sell ? currencyPair.counter.getCurrencyCode() : currencyPair.base.getCurrencyCode();
UserTrade trade =
new UserTrade.Builder()
UserTrade.builder()
.type(orderType)
.originalAmount(originalAmount)
.currencyPair(currencyPair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public static UserTrades adaptTradeHistory(BitstampUserTransaction[] bitstampUse
final CurrencyPair pair =
new CurrencyPair(t.getBaseCurrency().toUpperCase(), t.getCounterCurrency().toUpperCase());
UserTrade trade =
new UserTrade.Builder()
UserTrade.builder()
.type(orderType)
.originalAmount(t.getBaseAmount().abs())
.currencyPair(pair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static List<UserTrade> adaptUserTrades(List<BittrexOrder> bittrexUserTrad
return bittrexUserTrades.stream()
.map(
bittrexOrder ->
new UserTrade.Builder()
UserTrade.builder()
.type(
BittrexConstants.BUY.equalsIgnoreCase(bittrexOrder.getDirection())
? OrderType.BID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static UserTrade adaptTrade(BityOrder order) {
Date date = order.getTimestampCreated();
String orderId = order.getResourceUri();

return new UserTrade.Builder()
return UserTrade.builder()
.type(orderType)
.originalAmount(amount)
.currencyPair(currencyPair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static List<UserTrade> adaptUserTransactionsToUserTrades(

for (Bl3pUserTransactions.Bl3pUserTransaction t : transactions) {
UserTrade ut =
new UserTrade.Builder()
UserTrade.builder()
.currencyPair(CurrencyPair.BTC_EUR)
.id(Integer.toString(t.id))
.orderId(Integer.toString(t.orderId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static ExchangeMetaData adaptToExchangeMetaData(
public static UserTrade adaptUserTrade(BluetradeExecutedTrade trade) {
OrderType orderType = trade.type.equalsIgnoreCase("sell") ? OrderType.ASK : OrderType.BID;
CurrencyPair currencyPair = BleutradeUtils.toCurrencyPair(trade.exchange);
return new UserTrade.Builder()
return UserTrade.builder()
.type(orderType)
.originalAmount(trade.quantity)
.currencyPair(currencyPair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private static String generateClOrdId() {

public static UserTrades toUserTrades(List<BlockchainOrder> blockchainTrades) {
List<UserTrade> trades = blockchainTrades.stream()
.map(blockchainTrade -> new UserTrade.Builder()
.map(blockchainTrade -> UserTrade.builder()
.type(blockchainTrade.getOrderType())
.originalAmount(blockchainTrade.getCumQty())
.currencyPair(blockchainTrade.getSymbol())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static UserTrade adaptTrade(BTCMarketsUserTrade trade, CurrencyPair curre
final String tradeId = Long.toString(trade.getId());
final Long orderId = trade.getOrderId();
final String feeCurrency = currencyPair.counter.getCurrencyCode();
return new UserTrade.Builder()
return UserTrade.builder()
.type(type)
.originalAmount(trade.getVolume())
.currencyPair(currencyPair)
Expand All @@ -172,7 +172,7 @@ public static UserTrade adaptTradeHistory(BTCMarketsTradeHistoryResponse trade)
final String orderId = trade.orderId;
final String feeCurrency = currencyPair.counter.getCurrencyCode();
try {
return new UserTrade.Builder()
return UserTrade.builder()
.type(type)
.originalAmount(trade.amount)
.currencyPair(currencyPair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected static LimitOrder[] expectedOrders() {

protected static UserTrade[] expectedUserTrades() {
return new UserTrade[] {
new UserTrade.Builder()
UserTrade.builder()
.type(Order.OrderType.ASK)
.originalAmount(new BigDecimal("20.00000000"))
.currencyPair(CurrencyPair.BTC_AUD)
Expand All @@ -167,7 +167,7 @@ protected static UserTrade[] expectedUserTrades() {
.feeAmount(BigDecimal.ONE)
.feeCurrency(Currency.AUD)
.build(),
new UserTrade.Builder()
UserTrade.builder()
.type(Order.OrderType.ASK)
.originalAmount(new BigDecimal("40.00000000"))
.currencyPair(CurrencyPair.BTC_AUD)
Expand All @@ -177,7 +177,7 @@ protected static UserTrade[] expectedUserTrades() {
.feeAmount(BigDecimal.valueOf(2))
.feeCurrency(Currency.AUD)
.build(),
new UserTrade.Builder()
UserTrade.builder()
.type(Order.OrderType.BID)
.originalAmount(new BigDecimal("60.00000000"))
.currencyPair(CurrencyPair.BTC_AUD)
Expand All @@ -187,7 +187,7 @@ protected static UserTrade[] expectedUserTrades() {
.feeAmount(BigDecimal.valueOf(3))
.feeCurrency(Currency.AUD)
.build(),
new UserTrade.Builder()
UserTrade.builder()
.type(Order.OrderType.BID)
.originalAmount(new BigDecimal("80.00000000"))
.currencyPair(CurrencyPair.BTC_AUD)
Expand All @@ -197,7 +197,7 @@ protected static UserTrade[] expectedUserTrades() {
.feeAmount(BigDecimal.valueOf(4))
.feeCurrency(Currency.AUD)
.build(),
new UserTrade.Builder()
UserTrade.builder()
.type(Order.OrderType.BID)
.originalAmount(BigDecimal.ZERO)
.currencyPair(CurrencyPair.BTC_AUD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException
for (BTCTurkUserTransactions transaction : transactions) {
if (transaction.getOperation().equals(BTCTurkOperations.trade))
trades.add(
new UserTrade.Builder()
UserTrade.builder()
.type(
((transaction.getAmount().compareTo(BigDecimal.ZERO) > 0)
? OrderType.ASK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static UserTrade adaptUserTrade(CCEXOrderhistory trade) {
price = trade.getLimit();
}

return new UserTrade.Builder()
return UserTrade.builder()
.type(orderType)
.originalAmount(amount)
.currencyPair(currencyPair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public static UserTrade adaptArchivedOrder(CexIOArchivedOrder cexIOArchivedOrder
: Currency.getInstance(cexIOArchivedOrder.feeCcy);
BigDecimal fee = cexIOArchivedOrder.feeValue;

return new UserTrade.Builder()
return UserTrade.builder()
.type(orderType)
.originalAmount(originalAmount)
.currencyPair(currencyPair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static UserTrades adaptTrades(List<CoinbaseBuySell> transactions, OrderTy
}

private static UserTrade adaptTrade(CoinbaseBuySell transaction, OrderType orderType) {
return new UserTrade.Builder()
return UserTrade.builder()
.type(orderType)
.originalAmount(transaction.getAmount().getAmount())
.currencyPair(
Expand Down Expand Up @@ -101,7 +101,7 @@ public static UserTrade adaptTrade(CoinbaseTransfer transfer) {
final BigDecimal feeAmount = transfer.getCoinbaseFee().getAmount();
final String feeCurrency = transfer.getCoinbaseFee().getCurrency();

return new UserTrade.Builder()
return UserTrade.builder()
.type(orderType)
.originalAmount(originalAmount)
.currencyPair(new CurrencyPair(tradableIdentifier, transactionCurrency))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testAdaptTrades() throws IOException {
BigDecimal price = new BigDecimal("905.10").divide(originalAmount, RoundingMode.HALF_EVEN);

UserTrade expectedTrade =
new UserTrade.Builder()
UserTrade.builder()
.type(OrderType.BID)
.originalAmount(originalAmount)
.currencyPair(CurrencyPair.BTC_USD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public static UserTrades adaptTradeHistory(List<CoinbaseProFill> coinbaseExFills
CurrencyPair currencyPair = new CurrencyPair(fill.getProductId().replace('-', '/'));

trades.add(
new UserTrade.Builder()
UserTrade.builder()
.type("buy".equals(fill.getSide()) ? OrderType.BID : OrderType.ASK)
.originalAmount(fill.getSize())
.currencyPair(currencyPair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static UserTrades adaptToUserTrades(List<CoindealTradeHistory> coindealTr
CurrencyPair currencyPair =
CurrencyPairDeserializer.getCurrencyPairFromString(coindealTradeHistory.getSymbol());
userTrades.add(
new UserTrade.Builder()
UserTrade.builder()
.type(
(coindealTradeHistory.getSide().equals("BUY"))
? Order.OrderType.BID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException
if (t.executedAmount == null || t.executedAmount.signum() == 0) {
return null;
}
return new UserTrade.Builder()
return UserTrade.builder()
.type(CoindirectAdapters.convert(t.side))
.originalAmount(t.executedAmount)
.currencyPair(CoindirectAdapters.toCurrencyPair(t.symbol))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static UserTrades adaptTradeHistory(CoinEggTradeView coinEggTradeView) {
.timestamp(coinEggTradeView.getDateTime())
.build();

trades.add((UserTrade) UserTrade.Builder.from(trade).build());
trades.add((UserTrade) UserTrade.builder().from(trade).build());

return new UserTrades(trades, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static UserTrades adaptTradeHistory(Collection<CoinfloorUserTransaction>
final BigDecimal feeAmount = transaction.getFee();

UserTrade trade =
new UserTrade.Builder()
UserTrade.builder()
.type(transaction.getSide())
.originalAmount(transaction.getAmount().abs())
.currencyPair(transaction.getCurrencyPair())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public static UserTrades adaptTradeHistory(CoingiOrdersList ordersList) {
o.getCurrencyPair().get("counter").toUpperCase());

UserTrade trade =
new UserTrade.Builder()
UserTrade.builder()
.type(orderType)
.originalAmount(o.getOriginalBaseAmount())
.currencyPair(pair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static LimitOrder adaptOrderToLimitOrder(CoinjarOrder coinjarOrder) {
}

public static UserTrade adaptOrderToUserTrade(CoinjarOrder order) {
return new UserTrade.Builder()
return UserTrade.builder()
.id(order.oid.toString())
.orderId(order.oid.toString())
.currencyPair(productToCurrencyPair(order.productId))
Expand Down Expand Up @@ -165,7 +165,7 @@ public static OrderBook adaptOrderbook(CoinjarOrderBook orderBook, CurrencyPair
}

public static UserTrade adaptFillToUserTrade(CoinjarFill coinjarFill) {
return new UserTrade.Builder()
return UserTrade.builder()
.id(coinjarFill.tid.toString())
.orderId(coinjarFill.oid.toString())
.currencyPair(productToCurrencyPair(coinjarFill.productId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void testAdaptOrderToUserTrade() {
"2017-10-12T15:39:27.000+11:00");

final UserTrade expected =
new UserTrade.Builder()
UserTrade.builder()
.id("3267")
.orderId("3267")
.currencyPair(CurrencyPair.BTC_AUD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static Wallet adaptWallet(CoinmateBalance coinmateBalance) {
public static UserTrades adaptTransactionHistory(
CoinmateTransactionHistory coinmateTradeHistory) {
List<UserTrade> trades = coinmateTradeHistory.getData().stream().map(
entry -> new UserTrade.Builder()
entry -> UserTrade.builder()
.type(typeToOrderTypeOrNull(entry.getTransactionType()))
.originalAmount(entry.getAmount())
.currencyPair(
Expand All @@ -210,7 +210,7 @@ public static UserTrades adaptTransactionHistory(
}

public static UserTrades adaptTradeHistory(CoinmateTradeHistory coinmateTradeHistory) {
List<UserTrade> trades = coinmateTradeHistory.getData().stream().map(entry -> new UserTrade.Builder()
List<UserTrade> trades = coinmateTradeHistory.getData().stream().map(entry -> UserTrade.builder()
.type(typeToOrderTypeOrNull(entry.getType()))
.originalAmount(entry.getAmount())
.currencyPair(CoinmateUtils.getPair(entry.getCurrencyPair()))
Expand Down
Loading

0 comments on commit 01f9aa8

Please sign in to comment.