Class 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 with new 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()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FunctionalMethod

        public FunctionalMethod​(@NonNull
                                @NonNull java.lang.reflect.Method method)
    • 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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object