Streams in the Wild Java SE 8 - RainFocus...Streams Utils is a set of operations written on Java 8...

10
@ JosePaumard #J8Stream Streams in the Wild Java SE 8

Transcript of Streams in the Wild Java SE 8 - RainFocus...Streams Utils is a set of operations written on Java 8...

@JosePaumard#J8Stream

Streams in the Wild

Java SE 8

@JosePaumard#J8Stream

Agenda

About Java 8 Streams

Goal: to show advanced patterns of the Stream API

Based on the Spliterator API

@JosePaumard

@JosePaumard

https://github.com/JosePaumard

https://www.slideshare.net/jpaumard

https://www.youtube.com/user/JPaumard

@JosePaumard#J8Stream

Questions?

#J8Stream

@JosePaumard#J8Stream

Spliterators on spliterators

Building a Spliterator on another Spliterator allows:

Grouping: [1, 2, 3, 4, 5, …] ->

[[1, 2, 3], [4, 5, 6], [7, 8, 9], …]

Rolling: [1, 2, 3, 4, 5, …] ->

[[1, 2, 3], [2, 3, 4], [3, 4, 5], …]

Zipping: [1, 2, 3, …], [a, b, c, …] ->

[F[1, a], F[2, b], F[3, c], …]

@JosePaumard#J8Stream

Spliterators on spliterators

Building a Spliterator on another Spliterator allows:

Colllecting on a shifting window:

[a, b, c, d, e, …] ->

[[a, b, c], [b, c, d], [c, d, e], …]

[A, B, C, …]

collect collect collect

@JosePaumard#J8Stream

Conclusion

The Spliterator API can be used to connect streams to

custom sources

It can be used also to manipulate streams

https://github.com/JosePaumard/streams-utils

@JosePaumard#J8Stream

Thank you!

@JosePaumard#J8Stream