Skip to content

Commit c4a79bc

Browse files
committed
Fix javac warnings #877
1 parent 0296544 commit c4a79bc

File tree

29 files changed

+134
-113
lines changed

29 files changed

+134
-113
lines changed

.mvn/jvm.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Xmx1024m -Xms1024m -Djava.awt.headless=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/javax.crypto=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED
1+
-Xmx1024m -Xms1024m -Djava.awt.headless=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/javax.crypto=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED -Dmaven.compiler.showWarnings=true -Dmaven.compiler.showDeprecation=true

docs/docs/ressources/how-tos/how-to-create-a-release.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ description: How to create an official Cassandre release
55
---
66
# Create a release
77

8-
## Prepare the release
9-
* Fix [Codacy](https://app.codacy.com/gh/cassandre-tech/cassandre-trading-bot/issues) & Intellij warnings.
8+
## Things to check before release
9+
* Fix Intellij warnings.
10+
* Fix [Codacy](https://app.codacy.com/gh/cassandre-tech/cassandre-trading-bot/issues) warnings.
1011
* Update [security.md](https://github.com/cassandre-tech/cassandre-trading-bot/blob/development/SECURITY.md).
1112

1213
## Create the release with Maven
@@ -15,7 +16,7 @@ You must be using `ssh` and not `https`. To switch to `ssh`, type :
1516
git remote set-url origin [email protected]:cassandre-tech/cassandre-trading-bot.git
1617
```
1718

18-
Check that you are on the develop branch and that everything is committed:
19+
Check that you are on the `development` branch and that everything is committed:
1920
```bash
2021
git checkout development
2122
git status
@@ -35,3 +36,16 @@ mvn gitflow:release-finish
3536
* Close the corresponding [milestone in Github](https://github.com/cassandre-tech/cassandre-trading-bot/milestones?direction=asc&sort=due_date&state=open).
3637
* Write and send a [substack post](https://cassandre.substack.com/publish?utm_source=menu).
3738
* Update cassandre release number on production trading bots.
39+
40+
## Releases text
41+
* English: "We've just released Cassandre 5.0.7, a Spring boot starter to Create and run your java crypto trading bot in minutes. Details here: URL"
42+
* French: "Sortie de Cassandre 5.0.7, notre Spring Boot Starter qui permet de créer son propre bot de crypto-trading en quelques minutes. Les détails ici : URL"
43+
44+
## Tell the world
45+
* Retrieve the news URL from [substack](https://cassandre.substack.com/).
46+
* Publish on Cassandre Twitter (should be done by GitHub CI).
47+
* Publish on Cassandre Discord (should be done by GitHub CI).
48+
* Publish on my personal accounts (Facebook, Twitter & LinkedIn).
49+
* Publish on [linuxfr](https://linuxfr.org/).
50+
* Publish on [bitcointalk](https://bitcointalk.org/index.php?board=8.0).
51+
* Publish on

spring-boot-starter-api/spring-boot-starter-api-graphql/autoconfigure/src/main/java/tech/cassandre/trading/bot/api/graphql/data/OrderDataFetcher.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class OrderDataFetcher extends BaseDataFetcher {
3030
public final List<OrderDTO> orders() {
3131
return orderRepository.findAll()
3232
.stream()
33-
.map(orderMapper::mapToOrderDTO)
33+
.map(ORDER_MAPPER::mapToOrderDTO)
3434
.collect(Collectors.toList());
3535
}
3636

@@ -43,7 +43,7 @@ public final List<OrderDTO> orders() {
4343
@DgsQuery
4444
public OrderDTO order(@InputArgument final long id) {
4545
return orderRepository.findById(id)
46-
.map(orderMapper::mapToOrderDTO)
46+
.map(ORDER_MAPPER::mapToOrderDTO)
4747
.orElse(null);
4848
}
4949

@@ -56,7 +56,7 @@ public OrderDTO order(@InputArgument final long id) {
5656
@DgsQuery
5757
public OrderDTO orderByOrderId(@InputArgument final String orderId) {
5858
return orderRepository.findByOrderId(orderId)
59-
.map(orderMapper::mapToOrderDTO)
59+
.map(ORDER_MAPPER::mapToOrderDTO)
6060
.orElse(null);
6161
}
6262

spring-boot-starter-api/spring-boot-starter-api-graphql/autoconfigure/src/main/java/tech/cassandre/trading/bot/api/graphql/data/PositionDataFetcher.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class PositionDataFetcher extends BaseDataFetcher {
3232
public final List<PositionDTO> positions() {
3333
return positionRepository.findAll()
3434
.stream()
35-
.map(positionMapper::mapToPositionDTO)
35+
.map(POSITION_MAPPER::mapToPositionDTO)
3636
.collect(Collectors.toList());
3737
}
3838

@@ -45,7 +45,7 @@ public final List<PositionDTO> positions() {
4545
@DgsQuery
4646
public final PositionDTO position(@InputArgument final long id) {
4747
return positionRepository.findById(id)
48-
.map(positionMapper::mapToPositionDTO)
48+
.map(POSITION_MAPPER::mapToPositionDTO)
4949
.orElse(null);
5050
}
5151

@@ -60,7 +60,7 @@ public final List<PositionDTO> positionsByStrategy(@InputArgument final long id)
6060
return positionRepository.findAll()
6161
.stream()
6262
.filter(position -> position.getStrategy().getId() == id)
63-
.map(positionMapper::mapToPositionDTO)
63+
.map(POSITION_MAPPER::mapToPositionDTO)
6464
.collect(Collectors.toList());
6565
}
6666

@@ -75,7 +75,7 @@ public final List<PositionDTO> positionsByStrategyId(@InputArgument final String
7575
return positionRepository.findAll()
7676
.stream()
7777
.filter(position -> Objects.equals(position.getStrategy().getStrategyId(), strategyId))
78-
.map(positionMapper::mapToPositionDTO)
78+
.map(POSITION_MAPPER::mapToPositionDTO)
7979
.collect(Collectors.toList());
8080
}
8181

@@ -92,7 +92,7 @@ public final List<PositionDTO> positionsByStrategyAndStatus(@InputArgument final
9292
return positionRepository.findByStatus(status)
9393
.stream()
9494
.filter(position -> position.getStrategy().getId() == id)
95-
.map(positionMapper::mapToPositionDTO)
95+
.map(POSITION_MAPPER::mapToPositionDTO)
9696
.collect(Collectors.toList());
9797
}
9898

@@ -109,7 +109,7 @@ public final List<PositionDTO> positionsByStrategyIdAndStatus(@InputArgument fin
109109
return positionRepository.findByStatus(status)
110110
.stream()
111111
.filter(position -> Objects.equals(position.getStrategy().getStrategyId(), strategyId))
112-
.map(positionMapper::mapToPositionDTO)
112+
.map(POSITION_MAPPER::mapToPositionDTO)
113113
.collect(Collectors.toList());
114114
}
115115

spring-boot-starter-api/spring-boot-starter-api-graphql/autoconfigure/src/main/java/tech/cassandre/trading/bot/api/graphql/data/StrategyDataFetcher.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class StrategyDataFetcher extends BaseDataFetcher {
3030
public final List<StrategyDTO> strategies() {
3131
return strategyRepository.findAll()
3232
.stream()
33-
.map(strategyMapper::mapToStrategyDTO)
33+
.map(STRATEGY_MAPPER::mapToStrategyDTO)
3434
.collect(Collectors.toList());
3535
}
3636

@@ -43,7 +43,7 @@ public final List<StrategyDTO> strategies() {
4343
@DgsQuery
4444
public StrategyDTO strategy(@InputArgument final long id) {
4545
return strategyRepository.findById(id)
46-
.map(strategyMapper::mapToStrategyDTO)
46+
.map(STRATEGY_MAPPER::mapToStrategyDTO)
4747
.orElse(null);
4848
}
4949

@@ -56,7 +56,7 @@ public StrategyDTO strategy(@InputArgument final long id) {
5656
@DgsQuery
5757
public StrategyDTO strategyByStrategyId(@InputArgument final String strategyId) {
5858
return strategyRepository.findByStrategyId(strategyId)
59-
.map(strategyMapper::mapToStrategyDTO)
59+
.map(STRATEGY_MAPPER::mapToStrategyDTO)
6060
.orElse(null);
6161
}
6262

spring-boot-starter-api/spring-boot-starter-api-graphql/autoconfigure/src/main/java/tech/cassandre/trading/bot/api/graphql/data/TradeDataFetcher.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class TradeDataFetcher extends BaseDataFetcher {
3030
public final List<TradeDTO> trades() {
3131
return tradeRepository.findAll()
3232
.stream()
33-
.map(tradeMapper::mapToTradeDTO)
33+
.map(TRADE_MAPPER::mapToTradeDTO)
3434
.collect(Collectors.toList());
3535
}
3636

@@ -43,7 +43,7 @@ public final List<TradeDTO> trades() {
4343
@DgsQuery
4444
public final TradeDTO trade(@InputArgument final long id) {
4545
return tradeRepository.findById(id)
46-
.map(tradeMapper::mapToTradeDTO)
46+
.map(TRADE_MAPPER::mapToTradeDTO)
4747
.orElse(null);
4848
}
4949

@@ -56,7 +56,7 @@ public final TradeDTO trade(@InputArgument final long id) {
5656
@DgsQuery
5757
public final TradeDTO tradeByTradeId(@InputArgument final String tradeId) {
5858
return tradeRepository.findByTradeId(tradeId)
59-
.map(tradeMapper::mapToTradeDTO)
59+
.map(TRADE_MAPPER::mapToTradeDTO)
6060
.orElse(null);
6161
}
6262

spring-boot-starter/autoconfigure/src/main/java/tech/cassandre/trading/bot/batch/OrderFlux.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected final Set<OrderDTO> getNewValues() {
4444

4545
// If the local order is already saved in database and the order retrieved from the exchange
4646
// is different, then, we update the order in database.
47-
if (orderInDatabase.isPresent() && !orderMapper.mapToOrderDTO(orderInDatabase.get()).equals(order)) {
47+
if (orderInDatabase.isPresent() && !ORDER_MAPPER.mapToOrderDTO(orderInDatabase.get()).equals(order)) {
4848
logger.debug("Updated order from exchange: {}", order);
4949
newValues.add(order);
5050
}
@@ -61,18 +61,18 @@ protected final Set<OrderDTO> saveValues(final Set<OrderDTO> newValues) {
6161
newValues.forEach(newValue -> orderRepository.findByOrderId(newValue.getOrderId())
6262
.ifPresentOrElse(order -> {
6363
// Update order.
64-
orderMapper.updateOrder(newValue, order);
64+
ORDER_MAPPER.updateOrder(newValue, order);
6565
orders.add(orderRepository.save(order));
6666
logger.debug("Updating order in database: {}", order);
6767
}, () -> {
6868
// Create order.
69-
final Order newOrder = orderMapper.mapToOrder(newValue);
69+
final Order newOrder = ORDER_MAPPER.mapToOrder(newValue);
7070
orders.add(orderRepository.save(newOrder));
7171
logger.debug("Creating order in database: {}", newOrder);
7272
}));
7373

7474
return orders.stream()
75-
.map(orderMapper::mapToOrderDTO)
75+
.map(ORDER_MAPPER::mapToOrderDTO)
7676
.collect(Collectors.toCollection(LinkedHashSet::new));
7777
}
7878

spring-boot-starter/autoconfigure/src/main/java/tech/cassandre/trading/bot/batch/PositionFlux.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public final Set<PositionDTO> saveValues(final Set<PositionDTO> newValues) {
3636
final Optional<Position> position = positionRepository.findById(positionDTO.getId());
3737
if (position.isPresent()) {
3838
// If the position is in database (which should be always true), we update it.
39-
positionMapper.updatePosition(positionDTO, position.get());
39+
POSITION_MAPPER.updatePosition(positionDTO, position.get());
4040
positions.add(positionRepository.save(position.get()));
4141
logger.debug("Updating position in database: {}", positionDTO);
4242
} else {
@@ -45,7 +45,7 @@ public final Set<PositionDTO> saveValues(final Set<PositionDTO> newValues) {
4545
});
4646

4747
return positions.stream()
48-
.map(positionMapper::mapToPositionDTO)
48+
.map(POSITION_MAPPER::mapToPositionDTO)
4949
.collect(Collectors.toCollection(LinkedHashSet::new));
5050
}
5151

spring-boot-starter/autoconfigure/src/main/java/tech/cassandre/trading/bot/batch/TradeFlux.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected final Set<TradeDTO> getNewValues() {
4949
}
5050

5151
// The trade is in database but the trade values from the server changed.
52-
if (tradeInDatabase.isPresent() && !tradeMapper.mapToTradeDTO(tradeInDatabase.get()).equals(trade)) {
52+
if (tradeInDatabase.isPresent() && !TRADE_MAPPER.mapToTradeDTO(tradeInDatabase.get()).equals(trade)) {
5353
logger.debug("Updated trade from exchange: {}", trade);
5454
newValues.add(trade);
5555
}
@@ -66,20 +66,20 @@ public final Set<TradeDTO> saveValues(final Set<TradeDTO> newValues) {
6666
newValues.forEach(newValue -> tradeRepository.findByTradeId(newValue.getTradeId())
6767
.ifPresentOrElse(trade -> {
6868
// Update trade.
69-
tradeMapper.updateTrade(newValue, trade);
69+
TRADE_MAPPER.updateTrade(newValue, trade);
7070
trades.add(tradeRepository.save(trade));
7171
logger.debug("Updating trade in database: {}", trade);
7272
}, () -> {
7373
// Create trade.
74-
final Trade newTrade = tradeMapper.mapToTrade(newValue);
74+
final Trade newTrade = TRADE_MAPPER.mapToTrade(newValue);
7575
// Order is always present as we check it in getNewValues().
7676
orderRepository.findByOrderId(newValue.getOrderId()).ifPresent(newTrade::setOrder);
7777
trades.add(tradeRepository.save(newTrade));
7878
logger.debug("Creating trade in database: {}", newTrade);
7979
}));
8080

8181
return trades.stream()
82-
.map(tradeMapper::mapToTradeDTO)
82+
.map(TRADE_MAPPER::mapToTradeDTO)
8383
.collect(Collectors.toCollection(LinkedHashSet::new));
8484
}
8585

spring-boot-starter/autoconfigure/src/main/java/tech/cassandre/trading/bot/configuration/StrategiesAutoConfiguration.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ public void configure() {
238238
// positionService. Here we force the status recalculation, and we save it.
239239
positionRepository.findByStatusIn(Stream.of(OPENING, CLOSING).collect(Collectors.toSet()))
240240
.stream()
241-
.map(positionMapper::mapToPositionDTO)
242-
.map(positionMapper::mapToPosition)
241+
.map(POSITION_MAPPER::mapToPositionDTO)
242+
.map(POSITION_MAPPER::mapToPosition)
243243
.forEach(positionRepository::save);
244244

245245
// =============================================================================================================
@@ -279,7 +279,7 @@ public void configure() {
279279
// Update.
280280
existingStrategy.setName(annotation.strategyName());
281281
strategyRepository.save(existingStrategy);
282-
final StrategyDTO strategyDTO = strategyMapper.mapToStrategyDTO(existingStrategy);
282+
final StrategyDTO strategyDTO = STRATEGY_MAPPER.mapToStrategyDTO(existingStrategy);
283283
strategyDTO.initializeLastPositionIdUsed(positionRepository.getLastPositionIdUsedByStrategy(strategyDTO.getId()));
284284
strategy.setStrategy(strategyDTO);
285285
logger.debug("Strategy updated in database: {}.", existingStrategy);
@@ -296,7 +296,7 @@ public void configure() {
296296
newStrategy.setType(BASIC_TA4J_STRATEGY);
297297
}
298298
logger.debug("Strategy created in database: {}.", newStrategy);
299-
StrategyDTO strategyDTO = strategyMapper.mapToStrategyDTO(strategyRepository.save(newStrategy));
299+
StrategyDTO strategyDTO = STRATEGY_MAPPER.mapToStrategyDTO(strategyRepository.save(newStrategy));
300300
strategyDTO.initializeLastPositionIdUsed(positionRepository.getLastPositionIdUsedByStrategy(strategyDTO.getId()));
301301
strategy.setStrategy(strategyDTO);
302302
});

spring-boot-starter/autoconfigure/src/main/java/tech/cassandre/trading/bot/service/ExchangeServiceXChangeImplementation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public Set<CurrencyPairDTO> getAvailableCurrencyPairs() {
2727
.keySet()
2828
.stream()
2929
.peek(cp -> logger.debug(" - {} available", cp))
30-
.map(currencyMapper::mapToCurrencyPairDTO)
30+
.map(CURRENCY_MAPPER::mapToCurrencyPairDTO)
3131
.collect(Collectors.toCollection(LinkedHashSet::new));
3232
}
3333

spring-boot-starter/autoconfigure/src/main/java/tech/cassandre/trading/bot/service/MarketServiceXChangeImplementation.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Optional<TickerDTO> getTicker(final CurrencyPairDTO currencyPair) {
4444
bucket.asBlocking().consume(1);
4545

4646
logger.debug("Getting ticker for {} currency pair", currencyPair);
47-
TickerDTO t = tickerMapper.mapToTickerDTO(marketDataService.getTicker(currencyMapper.mapToCurrencyPair(currencyPair)));
47+
TickerDTO t = TICKER_MAPPER.mapToTickerDTO(marketDataService.getTicker(CURRENCY_MAPPER.mapToInstrument(currencyPair)));
4848
logger.debug(" - New ticker {}", t);
4949
return Optional.ofNullable(t);
5050
} catch (IOException e) {
@@ -62,7 +62,7 @@ public Set<TickerDTO> getTickers(final Set<CurrencyPairDTO> currencyPairs) {
6262
// We create the currency pairs parameters.
6363
CurrencyPairsParam params = () -> currencyPairs
6464
.stream()
65-
.map(currencyMapper::mapToCurrencyPair)
65+
.map(CURRENCY_MAPPER::mapToCurrencyPair)
6666
.collect(Collectors.toCollection(LinkedList::new));
6767

6868
// Consume a token from the token bucket.
@@ -72,7 +72,7 @@ public Set<TickerDTO> getTickers(final Set<CurrencyPairDTO> currencyPairs) {
7272
logger.debug("Getting tickers for {} currency pairs", currencyPairs.size());
7373
final List<Ticker> tickers = marketDataService.getTickers(params);
7474
return tickers.stream()
75-
.map(tickerMapper::mapToTickerDTO)
75+
.map(TICKER_MAPPER::mapToTickerDTO)
7676
.peek(t -> logger.debug(" - New ticker: {}", t))
7777
.collect(Collectors.toCollection(LinkedHashSet::new));
7878
} catch (IOException e) {

0 commit comments

Comments
 (0)