Skip to content

Commit

Permalink
[kraken] apply formatting with com.spotify.fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
donald-jackson committed Mar 28, 2024
1 parent e3443cb commit 1136d61
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,12 @@ public static OrderType adaptOrderType(KrakenType krakenType) {
return krakenType.equals(KrakenType.BUY) ? OrderType.BID : OrderType.ASK;
}

public static AddressWithTag adaptKrakenDepositAddress(KrakenDepositAddress[] krakenDepositAddress) {
public static AddressWithTag adaptKrakenDepositAddress(
KrakenDepositAddress[] krakenDepositAddress) {
return AddressWithTag.builder()
.address(krakenDepositAddress[0].getAddress())
.addressTag(krakenDepositAddress[0].getTag()).build();
.addressTag(krakenDepositAddress[0].getTag())
.build();
}

public static String adaptOrderId(KrakenOrderResponse orderResponse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@
import org.knowm.xchange.kraken.dto.account.results.WithdrawStatusResult;
import org.knowm.xchange.utils.DateUtils;

/** @author jamespedwards42 */
/**
* @author jamespedwards42
*/
@Slf4j
public class KrakenAccountServiceRaw extends KrakenBaseService {

private ConcurrentHashMap<String, KrakenDepositMethods[]> depositMethods = new ConcurrentHashMap<>();
private ConcurrentHashMap<String, KrakenDepositMethods[]> depositMethods =
new ConcurrentHashMap<>();

/**
* Constructor
Expand Down Expand Up @@ -88,14 +91,16 @@ public KrakenDepositMethods[] getDepositMethods(String assetPairs, String assets
throws IOException {
if (shouldCacheDepositMethods()) {
try {
return depositMethods.computeIfAbsent(String.format("%s%s", assetPairs, assets), k -> {
try {
return getDepositMethodsFromRemote(assetPairs, assets);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
} catch(RuntimeException e) {
return depositMethods.computeIfAbsent(
String.format("%s%s", assetPairs, assets),
k -> {
try {
return getDepositMethodsFromRemote(assetPairs, assets);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
} catch (RuntimeException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ public void testRequestDepositMethodCaching() {
loadFile(
"/org/knowm/xchange/kraken/dto/account/example-deposit-addresses-trx.json"))));

exchange.getExchangeSpecification().setExchangeSpecificParametersItem("cacheDepositMethods", true);
exchange
.getExchangeSpecification()
.setExchangeSpecificParametersItem("cacheDepositMethods", true);

DefaultRequestDepositAddressParams params =
DefaultRequestDepositAddressParams.builder().currency(Currency.TRX).build();
Expand Down Expand Up @@ -199,7 +201,9 @@ public void testRequestDepositMethodNoCache() {
DefaultRequestDepositAddressParams params =
DefaultRequestDepositAddressParams.builder().currency(Currency.TRX).build();

exchange.getExchangeSpecification().setExchangeSpecificParametersItem("cacheDepositMethods", false);
exchange
.getExchangeSpecification()
.setExchangeSpecificParametersItem("cacheDepositMethods", false);

classUnderTest.requestDepositAddress(params);
classUnderTest.requestDepositAddress(params);
Expand Down

0 comments on commit 1136d61

Please sign in to comment.