After running a query my code will have a list of Object ExchangeTradeStatus.
List<ExchangeTradeStatus> pendingBseUsers = exchangeTradeStatusRepository.findByStatus("PENDING");
ExchangeTradeStatus has a userId field. I want to create a Map<String, Boolean> using java streams to extract userId from each item in the list and by default set the Boolean as False for each Key.
Map<String, Boolean> pendingUcc = pendingBseUsers.stream().collect(Collectors.toMap(ExchangeTradeStatus::getUcc, Boolean.FALSE));
But clearly there's some mistake. Would want to know how to fix this or if this is even possible.
In fact, initially I wanted a Set which would have the 2 required fields but I wasn't sure If That was Possible without creating an additional class with the two member variables.
Update:
Set<UccTradingPermission> pendingBseUcc = pendingBseUsers.stream().map(user -> new UccTradingPermission(user.getUcc())).collect(Collectors.toSet());
that's the only way I can think of to create a Set where the class used is:
public class UccTradingPermission {
String ucc;
Boolean status = Boolean.FALSE
public UccTradingPermission(String ucc){
this.ucc = ucc;
}
}