I have a problem with groupingBy collecting. In my case all elements in list have unique addressType value. I want to get a Map<String, Address> but have Map<String, Optional<Address>>
List<Address> list = ....
Map<String, Optional<Address>> collect = list.stream()
.collect(Collectors.groupingBy(Address::getAddressType,
Collectors.reducing((o, o2) -> o)));