DEV Community

loading...
Cover image for How to bind methods or constructors to functional interfaces in Java

How to bind methods or constructors to functional interfaces in Java

Burningwave
Burningwave is a set consisting of a Java frameworks building library and other applications and frameworks based on it
Updated on ・2 min read

To bind methods or constructors to functional interfaces we are going to use the FunctionalInterfaceFactory. FunctionalInterfaceFactory component uses to cache all generated functional interfaces for faster access. First of all we must add the following dependency to our pom.xml:

Constructors binding

To bind constructors to functional interfaces we will use the following constructors:


... And now let's see the code needed to bind and call the generated functional interfaces:

Methods binding

To bind methods to functional interfaces we will use the following methods:


... And now let's see the code needed to bind and call the generated functional interfaces:

Void methods binding

To bind void methods to functional interfaces we will use the following methods:


... And now let's see the code needed to bind and call the generated functional interfaces:

Binding to methods with boolean return

To bind methods with boolean return to functional interfaces we will use the following methods:


... And now let's see the code needed to bind and call the generated functional interfaces:

In this article we learned how to bind methods or constructors to functional interfaces and the complete source is available here.

Discussion (0)