In this recipe, you will learn how to create and use a custom functional interface when none of the standard interfaces in the java.util.function package satisfies the requirements.
Creating a functional interface
Getting ready
Creating a functional interface is easy. One just has to make sure there is only one abstract method in the interface, including methods inherited from other interfaces:
@FunctionalInterface
interface A{
void m1();
}
@FunctionalInterface
interface B extends A{
default void m2(){};
}
//@FunctionalInterface
interface C extends B{
void m3();
}
In the preceding example, interface C is not a functional interface because it has two abstract methods—m1(), inherited from interface A, and its own method...