Interface ExtensionHandler

    • Field Detail

      • EQUALS_HANDLER

        static final ExtensionHandler EQUALS_HANDLER
        Implementation for the Object.equals(Object) method. Each object using this handler is only equal to ifself.
      • HASHCODE_HANDLER

        static final ExtensionHandler HASHCODE_HANDLER
        Implementation for the Object.hashCode() method.
      • NULL_HANDLER

        static final ExtensionHandler NULL_HANDLER
        Handler that only returns null independent of any input parameters.
    • Method Detail

      • invoke

        java.lang.Object invoke​(HandleSupplier handleSupplier,
                                java.lang.Object target,
                                java.lang.Object... args)
                         throws java.lang.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:
        java.lang.Exception - Any exception from the underlying code
      • warm

        @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

        static ExtensionHandler missingExtensionHandler​(java.lang.reflect.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

        static ExtensionHandler createForMethod​(java.lang.reflect.Method method)
                                         throws java.lang.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:
        java.lang.IllegalAccessException - If the method could not be unreflected
      • createForSpecialMethod

        static ExtensionHandler createForSpecialMethod​(java.lang.reflect.Method method)
                                                throws java.lang.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:
        java.lang.IllegalAccessException - If the method could not be unreflected
      • createForMethodHandle

        static ExtensionHandler createForMethodHandle​(java.lang.invoke.MethodHandle methodHandle)
        Create an extension handler and bind it to a MethodHandle instance.
        Parameters:
        methodHandle - The MethodHandle to bind to
        Returns:
        An ExtensionHandler
        Throws:
        java.lang.IllegalAccessException - If the method could not be unreflected