Package com.bakdata.util
Class FunctionalMethod<T>
- java.lang.Object
-
- com.bakdata.util.FunctionalMethod<T>
-
- Type Parameters:
T
- the type of the class.
public final class FunctionalMethod<T> extends java.lang.Object
A lambda wrapper around the a method of a class. The wrapped method can be used as a lambda withnew FunctionalMethod(m)::invoke
.
-
-
Constructor Summary
Constructors Constructor Description FunctionalMethod(@NonNull java.lang.reflect.Method method)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
@NonNull java.lang.reflect.Method
getMethod()
The wrapped method.int
hashCode()
<R> R
invoke(T instance, java.lang.Object... params)
Invokes the method on an instance with the given parameters.java.lang.String
toString()
-
-
-
Method Detail
-
invoke
@NonNull public <R> R invoke(T instance, java.lang.Object... params)
Invokes the method on an instance with the given parameters.- Parameters:
instance
- the instance, on which to invoke the method, or null for static methods.params
- the parameters to pass to the method.- Returns:
- the result.
- Sneaky Throws:
- IllegalAccessException (sneaky), Exception if any
InvocationTargetException
occurs
-
getMethod
@NonNull public @NonNull java.lang.reflect.Method getMethod()
The wrapped method.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-