using a stream based on the content of Optional<Map>
问题 I get a map from a service not under my control that might be null and want to process it, let's say, filter, map and reduce to a single element I need. Question: is there a "link" from Optional to Stream? I tried (among other things): return Optional.ofNullable(getMap()) .map(Map::entrySet) // gets the entryset .map(Stream::of) .orElseGet(Stream::empty) // i would then like to continue with .filter(e -> e.getKey().startsWith("f") .map(Entry::getValue) .findFirst(); but then I get not Stream