Java Next Steps: Stream Collectors
Creating custom collectors for tighter, safer, and more testable code
Java streams have allowed Java developers to adopt a more functional style approach in their work, often eliminating the use of traditional loops. However, many still limit themselves to using the default utilities that are packed with the JDK.
Expert Abraham Marín-Pérez offers an introduction to Java streams and existing collectors. Join in to discover how to build your own stream collectors for safer, cleaner code and better error handling. By learning how and when to create your own stream collectors, you’ll be able to write code that’s more closely aligned to your needs, making it more readable, reusable, and testable.
What you'll learn-and how you can apply it
By the end of this live online course, you’ll understand:
- The various ways of extracting data from a stream—and their differences
- The limitations of the default collectors
- The internal mechanics of how collectors work
And you’ll be able to:
- Create your own collectors by extending existing ones
- Create your own collectors from scratch
- Reduce your code footprint by reusing common logic packed in collectors
- Write more expressive code with explicitly named collectors
- Ease diagnosis of error conditions by adding checks and detailed messages in your collectors
This training course is for you because...
- You’re a Java developer.
- You work with Java streams.
- You want to improve your functional programming skills in Java.
- A working knowledge of Java streams
- A computer with JDK 8 (or later) and a modern IDE (e.g., IntelliJ IDEA, Eclipse, NetBeans) installed and configured
- Take Java Next Steps: Collections, Generics, and Streams (live online training course with Ben Evans)
- Watch Java 8 Lambdas and Streams (video, 4h 25m)
About your instructor
Abraham Marín-Pérez is a Java programmer, consultant, author, and public speaker with more than ten years of experience in industries ranging from finance to publishing to the public sector. After graduating in Computer Science from the University of Valencia, Spain, Abraham relocated to London, UK, where he built his career working with entities like JP Morgan, Springer Nature, or the United Kingdom’s Home Office, among others. Thinking his experiences could be useful to others, Abraham became a Java news editor at InfoQ, authored “Real-World Maintainable Software” (O’Reilly, 2016), and co-authored “Continuous Delivery in Java” (O’Reilly, 2018). Always the learner, Abraham is currently studying a degree in Physics. He also helps run the London Java Community, and provides career advice at the Meet a Mentor group.
The timeframes are only estimates and may vary according to how the class is progressing
Review of streams (35 minutes)
- Presentation: Definition of streams; reduce, collect, and other terminal operations; existing collectors
Creating simple collectors: Part 1 (20 minutes)
- Presentation and demo: A collector for safer code
Break (5 minutes)
Creating simple collectors: Part 2 (55 minutes)
- Presentation and demo: A collector for less verbose code; a collector for better error handling
Break (5 minutes)
Creating collectors: The general case (45 minutes)
- Presentation and demo: Anatomy of the general collector; creating of a general collector; parallel collectors
- Hands-on exercise: Accept X,Y coordinates from the command line
Wrap-up and Q&A (15 minutes)