Given Guava Immutable table, i need to process all cell and and filter out some cells based on some mapper result which returns Java Optional,
immutbleTable.cellSet()
.parallelStream()
.map(cell -> processAndGetOptionalResult(cell))
.filter(cell -> cell.isPresent())
.map(cell -> cell.get())
.collect(Collector.of(
ImmutableTable.Builder::new,
ImmutableTable.Builder::put,
(l, r) -> l.putAll(r.build()),
ImmutableTable.Builder<String,String,String>::build)
);
}
Is there a better way to achieve this ? Is there a way that i can remove "map(cell -> cell.get())" and collect cell.get() via accumulator itself?