Skip to content

Commit

Permalink
#169 - Added Lombok + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gazbert committed Nov 12, 2024
1 parent 58c6b7a commit 47460ac
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 419 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ private String extractIoErrorMessage(HttpURLConnection exchangeConnection) throw
}

private static String assertItemExists(String itemName, String itemValue) {
if (itemValue == null || itemValue.length() == 0) {
if (itemValue == null || itemValue.isEmpty()) {
final String errorMsg =
itemName + CONFIG_IS_NULL_OR_ZERO_LENGTH + EXCHANGE_CONFIG_FILE + " ?";
log.error(errorMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ private ExchangeHttpResponse sendAuthenticatedRequestToExchange(
// Build the URL with query param args in it
final StringBuilder postData = new StringBuilder();
for (final Map.Entry<String, String> param : params.entrySet()) {
if (postData.length() > 0) {
if (!postData.isEmpty()) {
postData.append("&");
}
postData.append(param.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ private ExchangeHttpResponse sendAuthenticatedRequestToExchange(
// Build the URL with query param args in it - yuk!
final StringBuilder postData = new StringBuilder();
for (final Map.Entry<String, String> param : params.entrySet()) {
if (postData.length() > 0) {
if (!postData.isEmpty()) {
postData.append("&");
}
postData.append(param.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import com.gazbert.bxbot.exchange.api.PairPrecisionConfig;
import java.math.BigDecimal;
import java.util.Map;
import lombok.ToString;

/**
* Default implementation of {@link PairPrecisionConfig} backed by {@link Map}s.
*
* @author maiph
*/
@ToString
public class PairPrecisionConfigImpl implements PairPrecisionConfig {

private final Map<String, Integer> prices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
package com.gazbert.bxbot.exchanges.trading.api.impl;

import com.gazbert.bxbot.trading.api.BalanceInfo;
import com.google.common.base.MoreObjects;
import java.math.BigDecimal;
import java.util.Map;
import lombok.Data;

/**
* A BalanceInfo implementation that can be used by Exchange Adapters.
*
* @author gazbert
*/
@Data
public final class BalanceInfoImpl implements BalanceInfo {

private Map<String, BigDecimal> balancesAvailable;
Expand All @@ -49,40 +50,4 @@ public BalanceInfoImpl(
this.balancesAvailable = balancesAvailable;
this.balancesOnHold = balancesOnHold;
}

@Override
public Map<String, BigDecimal> getBalancesAvailable() {
return balancesAvailable;
}

/**
* Sets the balances available.
*
* @param balancesAvailable the balances available.
*/
public void setBalancesAvailable(Map<String, BigDecimal> balancesAvailable) {
this.balancesAvailable = balancesAvailable;
}

@Override
public Map<String, BigDecimal> getBalancesOnHold() {
return balancesOnHold;
}

/**
* Sets the balances on hold.
*
* @param balancesOnHold the balances on hold.
*/
public void setBalancesOnHold(Map<String, BigDecimal> balancesOnHold) {
this.balancesOnHold = balancesOnHold;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("balancesAvailable", balancesAvailable)
.add("balancesOnHold", balancesOnHold)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@

import com.gazbert.bxbot.trading.api.MarketOrder;
import com.gazbert.bxbot.trading.api.MarketOrderBook;
import com.google.common.base.MoreObjects;
import java.util.List;
import lombok.Data;

/**
* A MarketOrderBook implementation that can be used by Exchange Adapters.
*
* @author gazbert
*/
@Data
public final class MarketOrderBookImpl implements MarketOrderBook {

private String marketId;
Expand All @@ -52,55 +53,4 @@ public MarketOrderBookImpl(
this.sellOrders = sellOrders;
this.buyOrders = buyOrders;
}

@Override
public String getMarketId() {
return marketId;
}

/**
* Sets the market id.
*
* @param marketId the market id.
*/
public void setMarketId(String marketId) {
this.marketId = marketId;
}

@Override
public List<MarketOrder> getSellOrders() {
return sellOrders;
}

/**
* Sets the sell orders.
*
* @param sellOrders the sell orders.
*/
public void setSellOrders(List<MarketOrder> sellOrders) {
this.sellOrders = sellOrders;
}

@Override
public List<MarketOrder> getBuyOrders() {
return buyOrders;
}

/**
* Sets the buy orders.
*
* @param buyOrders the buy orders.
*/
public void setBuyOrders(List<MarketOrder> buyOrders) {
this.buyOrders = buyOrders;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("marketId", marketId)
.add("sellOrders", sellOrders)
.add("buyOrders", buyOrders)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@

import com.gazbert.bxbot.trading.api.MarketOrder;
import com.gazbert.bxbot.trading.api.OrderType;
import com.google.common.base.MoreObjects;
import java.math.BigDecimal;
import lombok.Data;

/**
* A MarketOrder implementation that can be used by Exchange Adapters.
*
* @author gazbert
*/
@Data
public final class MarketOrderImpl implements MarketOrder {

private OrderType type;
Expand All @@ -54,70 +55,4 @@ public MarketOrderImpl(OrderType type, BigDecimal price, BigDecimal quantity, Bi
this.quantity = quantity;
this.total = total;
}

@Override
public OrderType getType() {
return type;
}

/**
* Sets the order type.
*
* @param type the order type.
*/
public void setType(OrderType type) {
this.type = type;
}

@Override
public BigDecimal getPrice() {
return price;
}

/**
* Sets the price.
*
* @param price the price.
*/
public void setPrice(BigDecimal price) {
this.price = price;
}

@Override
public BigDecimal getQuantity() {
return quantity;
}

/**
* Sets the quantity.
*
* @param quantity the quantity.
*/
public void setQuantity(BigDecimal quantity) {
this.quantity = quantity;
}

@Override
public BigDecimal getTotal() {
return total;
}

/**
* Sets the total.
*
* @param total the total.
*/
public void setTotal(BigDecimal total) {
this.total = total;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("type", type)
.add("price", price)
.add("quantity", quantity)
.add("total", total)
.toString();
}
}
Loading

0 comments on commit 47460ac

Please sign in to comment.