Given a Map<String, Either<Boolean, Integer>
, what's the most straightforward way to convert it to a Map<String, Boolean>
containing only the entries with boolean values?
Right now I have this:
Map<String, Boolean> boolMap = eitherMap
.filter(entry -> entry._2.isLeft())
.map((key, value) -> Tuple.of(key, value.getLeft())
;
This works, but seems unnecessarily wordy, and it seems like there should be some tighter, one-step, “flatmap that ” solution.