1 2 3 4 5 6 7 8 9 10 11 12 13
| public Map<Bank, List<Account>> findAllGroupByBank() { Map<Bank, List<Account>> result = new HashMap<>(); this.accountService .findAll() .stream() .forEach(a -> result.computeIfAbsent(a.getBank(), this::findAllByBank)); return result; }
private List<Account> findAllByBank(Bank aBank) { return this.accountService.findAll().stream().filter(account -> aBank.equals(account.getBank())).collect(Collectors.toList()); }
|