Although support for Streams was added to Java almost seven years ago, providing a breeze of fresh (and functional) air, few people have dived into the world of creating custom Collectors. By learning how and when to create your own Stream Collectors, you will be able to create code that is more closely aligned to your needs, making it more readable, reusable, safer, and testable. This will be taught through a number of real-life scenarios such as error conditions that are being masked by other errors, or shared logic with no natural place to be that is typically dumped into the usual Utils library, among other examples. Abraham will show you custom Collectors can provide an elegant and tidy solution to these situations. After this workshop, you will never look at Collectors the same way again.
1. A brief refresher on how Streams and Stream Collectors work in Java
2. An introduction of different scenarios where creating custom collectors may be useful
3. An explanation of how collectors are implemented in the JDK
4. Two different ways to create custom collectors (native, and reusing existing ones).
1. A working development environment with Java 8+ (Java 11+ recommended)
3. Working knowledge of Java Streams
Abraham Marin-Perez is a Java developer with more than ten years of experience in industries ranging from finance to publishing to the public sector. He also helps run the London Java Community, and provides career advice at the Meet a Mentor London group.
Abraham likes sharing his experiences with others, which has led him to become a Java News Editor at InfoQ, and to author "Real-World Maintainable Software" (O'Reilly), and co-author “Continuous Delivery in Java” (O’Reilly).
Currently based in London, Abraham likes going out on a hike whenever the English weather permits it, and cooking when it doesn't.