O'Reilly logo

Learning Java Functional Programming by Richard M Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating composite functions prior to Java 8

Prior to Java 8 it was possible to affect this type of operation using a specialized library such as http://www.functionaljava.org/ or by creating a class and interface first. We will demonstrate the latter approach here.

The interface will permit two methods to be combined. To illustrate this approach, we will declare a class called Compose. Within the class, we will declare a CompositionFunction interface, containing a single call method along with a compose method. The compose method returns an instance of the CompositionFunction interface using two CompositionFunction interface instances passed to it. The call method does the actual work.

The first part of the Compose class and the CompositionFunction ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required