I cannot see what the problem is with my stream api logic. It tells me the following
[ERROR] mystuff/MandantContentFetcher.java:[67,23] incompatible types: java.lang.Object cannot be converted to java.util.List
this is my stream method:
static List<MandantLinkCheckerEntry> createMandantLinkCheckerEntries(Struct struct) {
Map<String, Object> linkCheckerMandants = struct.toNestedMaps();
return linkCheckerMandants.values().parallelStream()
.map(Map.class::cast)
.map(MandantLinkCheckerEntry::convertMapToMandantCheckerEntry)
.collect(Collectors.toList());
}
which uses this method reference:
private static MandantLinkCheckerEntry convertMapToMandantCheckerEntry(Map<String, Object> entryToConvert) {
return new MandantLinkCheckerEntry(String.valueOf(entryToConvert.get("mandant.path")),
String.valueOf(entryToConvert.get("mail.to")),
Boolean.valueOf(String.valueOf(entryToConvert.get("active"))));
}
Why does he see a Object? The method reference in the 2nd map does return a MandantLinkCheckerEntry. Also I assume collect does create a List with the streamed values as generic type but it seems that he converts the type of the stream (which is Object here as the Stream initiator is Map<String, Object). How can I help him cast this to a List?