O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

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

How it works...

We talked about the first two of the listed practices in the Understanding and creating a functional interface recipe. The advantage of using the interfaces of the java.util.function package is based on two facts. First, any standardization facilitates better understanding and ease of API usage. Second, it facilitates minimal code writing.

To illustrate these considerations, let's try to create an API and call it GrandApi--an interface that is going to be implemented in the GrandApiImpl class. 

Let's add a method to our new API that allows the client to pass a function that calculates something. Such an arrangement allows a client to customize the behavior of the API as needed. This design is called a delegation pattern. It ...

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