Chapter 3. Function Composition and Fluent Interfaces

Having discussed the nature of functions in Java 8, we will now focus on the various ways in which functions can be composed. By compose, we mean how they can be combined in interesting and powerful ways. These techniques include basic function composition and the use of fluent interfaces.

Function composition is concerned with combining two functions to form a third one. Using the output of one function as the input to another one is a common practice. By combining two such functions, we are able to create more complex functions, which can be reused.

We will examine the basic approach for composing functions and then move on to the use of the Function interface and its compose and andThen methods. ...

Get Learning Java Functional Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.