Interface ExtensionHandler

All Known Subinterfaces:
Handler
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface @Alpha public interface ExtensionHandler
Provides functionality for a single method on an extension object. Each extension handler can either call another piece of code to return the result (e.g. the method on the underlying object) or return the result itself.
Since:
3.38.0
  • Field Details Link icon

  • Method Details Link icon

    • invoke Link icon

      Object invoke(HandleSupplier handleSupplier, Object target, Object... args) throws Exception
      Gets invoked to return a value for the method that this handler was bound to.
      Parameters:
      handleSupplier - A HandleSupplier instance for accessing the handle and its related objects
      target - The target object on which the handler should operate
      args - Optional arguments for the handler
      Returns:
      The return value for the method that was bound to the extension handler. Can be null
      Throws:
      Exception - Any exception from the underlying code
    • warm Link icon

      @Beta default void warm(ConfigRegistry config)
      Called after the method handler is constructed to pre-initialize any important configuration data structures.
      Parameters:
      config - the method configuration to use for warming up
    • missingExtensionHandler Link icon

      static ExtensionHandler missingExtensionHandler(Method method)
      Returns a default handler for missing functionality. The handler will throw an exception when invoked.
      Parameters:
      method - The method to which this specific handler instance is bound
      Returns:
      An ExtensionHandler instance
    • createForMethod Link icon

      static ExtensionHandler createForMethod(Method method) throws IllegalAccessException
      Create an extension handler and bind it to a method that will be called on the target object when invoked.
      Parameters:
      method - The Method to bind to
      Returns:
      An ExtensionHandler
      Throws:
      IllegalAccessException - If the method could not be unreflected
    • createForSpecialMethod Link icon

      static ExtensionHandler createForSpecialMethod(Method method) throws IllegalAccessException
      Create an extension handler and bind it to a special method that will be called on the target object when invoked. This is needed e.g. for interface default methods.
      Parameters:
      method - The Method to bind to
      Returns:
      An ExtensionHandler
      Throws:
      IllegalAccessException - If the method could not be unreflected
    • createForMethodHandle Link icon

      static ExtensionHandler createForMethodHandle(MethodHandle methodHandle)
      Create an extension handler and bind it to a MethodHandle instance.
      Parameters:
      methodHandle - The MethodHandle to bind to
      Returns:
      An ExtensionHandler