diff --git a/pl/java/features/stream/gatherer.txt b/pl/java/features/stream/gatherer.txt index d614848bd..62456f878 100644 --- a/pl/java/features/stream/gatherer.txt +++ b/pl/java/features/stream/gatherer.txt @@ -1 +1,31 @@ https://openjdk.org/jeps/461 + +2024 +CodeWiz - Stream Gatherers 0:00 of 16:56 + https://www.youtube.com/watch?v=qBcuOCzvS3Y + public static Gatherer, List> getFixedWindowGatherer(int limit) { + Supplier> initializer = ArrayList::new; + Gatherer.Integrator, T, List> integrator = (state, element, downstream) -> { + state.add.element(element); + if (state.size() == limit) { + var group = List.copyOf(state); + downstream.push(group); + state.clear(); + } + return true; // can consume more + }; + BiConsumer, Gatherer.Downstream>> finisher = (state, downstream) -> { + if (!state.isEmpty()) { + downstream.push(List.copyOf(state)); + } + }; + return Gatherer.ofSequential(initializer, integrator, finisher); + } + + List> employeePairList = employees.stream() + .filter(...) + .map(Employee::name) + .gather(getFixedWindowGatherer(2)) + .toList(); // [[Alice, Mary], [John, Ramesh], [Jen]] + + // standard Gatherers: windowFixed, fold, scan, mapConcurrent, windowSliding diff --git a/pl/java/tools/shell/jbang/docs/presentations.txt b/pl/java/tools/shell/jbang/docs/presentations.txt index 83db57202..84ed496f6 100644 --- a/pl/java/tools/shell/jbang/docs/presentations.txt +++ b/pl/java/tools/shell/jbang/docs/presentations.txt @@ -1,3 +1,7 @@ +2024 +Devoxx - jbang - Unleash the power of Java by Max Rydahl Andersen of 31:34 + https://www.youtube.com/watch?v=cpKwBbz1sf0 + ! catalog, edit, junit, ?profile 2021 Anderson - JBang: let's make Java fun to use again! 44:00 of 1:18:02 https://www.youtube.com/watch?v=5Gf1Dswl-gs