This is my code:
Map<String, Collection<? extends String>> test = listOfTipusIdentificadorPacient.stream()
.collect(Collectors.groupingBy(
TipusIdentificadorPacient::getOid,
Collectors.mapping(TipusIdentificadorPacient::getUse, Collectors.toList())
)
);
I'm getting this compilation message:
Type mismatch: cannot convert from Map<String,List> to Map<String,Collection<? extends String>>
I don't quite figure out how to override Collectors.mapping in order to:
return:
Map<String,Collection<? extends String>>
instead of:
Map<String,List<String>>
I've tried to create another generic code in order to make it to compile.
Code is:
Stream<Map.Entry<String, String>> streamOfPairedStrings = Stream.of();
Map<String, Collection<? extends String>> test = streamOfPairedStrings
.collect(Collectors.groupingBy(
Map.Entry::getKey,
Collectors.mapping(Pair::getValue, Collectors.toList())
)
);
Any ideas?