Summary

Method composition provides a flexible way of combining two or more functions into a single function. This offers flexibility that will otherwise not be present. We illustrate how this technique can be implemented using the Function interface. Its compose and andThen methods support the execution of functions before or after another function. We also demonstrated the usefulness of this technique by passing the composite functions to other methods allowing it be executed when needed.

Fluent interfaces are common in functional programming languages. We discussed the difference between this type of interface and the chaining and cascading techniques. While similar, chaining methods do not necessarily return the same object each time. Cascading ...

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.