I have two Spring Pages like this : Page<Account> and Page<Bank>.
class Account{
String name;
String bankId;
Bank bank;
}
I would like to setBank() for every Account object in the Page<Account> with the corresponding object from Page<Bank> based on the bankId.
I think I can use Java 8 streams for that.
So far, I've tried :
Map<String, Account> acc = account.stream()
.collect(Collectors.toMap(Account::getBankId, a -> a));
List<Bank> bk = bank.stream()
.map(b-> new Account(b.get(b.getBankId()), bk))
.collect(Collectors.toList());