Interface MemberInvoker

All Known Implementing Classes:
DefaultMemberInvoker

public interface MemberInvoker
Abstraction for invoking a Member (e.g. Method, Constructor, or Field) reflectively.

This interface provides a uniform API to invoke members on a target object with zero or more parameters.

See DefaultMemberInvoker for the main implementation which uses high-performance invocation strategies using method handles and lambdas as opposed to traditional Java reflection resulting in near-native invocation performance.

  • Method Summary

    Modifier and Type
    Method
    Description
     
    default Object
    invoke(Object target)
    Invokes the member with no parameters.
    invoke(Object target, int parameterCount, IntFunction<?> parameterProvider)
    Invokes the member with the provided number of parameters using a parameter provider.
    default Object
    invoke(Object target, Object param)
    Invokes the member with a single parameter.
    default Object
    invoke(Object target, Object... params)
    Invokes the member with a variable number of parameters.
  • Method Details

    • invoke

      default Object invoke(Object target)
      Invokes the member with no parameters.
      Parameters:
      target - the target object or null for static members
      Returns:
      the result of the invocation (or null for void-returning methods)
    • invoke

      default Object invoke(Object target, Object param)
      Invokes the member with a single parameter.
      Parameters:
      target - the target object
      param - the single parameter
      Returns:
      the invocation result
    • invoke

      default Object invoke(Object target, Object... params)
      Invokes the member with a variable number of parameters.
      Parameters:
      target - the target object or null for static members
      params - the parameters to pass
      Returns:
      the result of the invocation
    • invoke

      Object invoke(Object target, int parameterCount, IntFunction<?> parameterProvider)
      Invokes the member with the provided number of parameters using a parameter provider.
      Parameters:
      target - the target object
      parameterCount - the number of parameters to use
      parameterProvider - a function to supply parameters by index
      Returns:
      the invocation result
    • getMember

      Member getMember()
      Returns:
      the underlying reflective member