How to bind methods or constructors to functional interfaces in Java

Burningwave
1 min readDec 9, 2020

--

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:

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 have learned how to bind methods or constructors to functional interfaces and the complete source is available here. For more articles about Burningwave Core you can go to the main page.

--

--

Burningwave

A collection of Java libraries for building frameworks and applications: https://www.burningwave.org