How to Bind Methods or Constructors to Functional Interfaces

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

XML
 




x


 
1
<dependency>
2
    <groupId>org.burningwave</groupId>
3
    <artifactId>core</artifactId>
4
    <version>8.12.6</version>
5
</dependency>



Constructors Binding

To bind a constructors to a functional interface, we will use the following constructor:

Static Binding Vs. Dynamic Binding in Java

Static Binding in Java

In this static binding, the binding can resolve at runtime or compile time. The binding process of all static, final and private methods is done at compile time.

Dynamic Binding in Java

Overriding in Java can be considered the best example of dynamic binding as both parent and child classes have the same method — that is, it doesn’t decide on the method to be called.