コード例 #1
0
 private String collectPlayerScoreInfo() {
   return playerRepository
       .findAll()
       .stream()
       .sorted((p1, p2) -> Integer.valueOf(p2.getScore()).compareTo(p1.getScore()))
       .map(player -> "Playername: " + player.getPlayerName() + " Score: " + player.getScore())
       .collect(Collectors.joining(" | "));
 }
コード例 #2
0
 private void updatePlayerScore(GameUpdate gameUpdate) {
   Player playerEntity = playerRepository.findOneByPlayerName(gameUpdate.getPlayerName());
   playerEntity.setScore(playerEntity.getScore() + gameUpdate.getScoreDelta());
   playerRepository.save(playerEntity);
 }