Class HookControlImpl<T>

  • Type Parameters:
    T - self type
    All Implemented Interfaces:
    HookControl<T>

    public class HookControlImpl<T>
    extends java.lang.Object
    implements HookControl<T>
    Control implementation for hooks.
    • Constructor Detail

      • HookControlImpl

        public HookControlImpl​(T self,
                               java.lang.Object proxy,
                               FluentControl control,
                               ComponentInstantiator instantiator,
                               java.util.function.Supplier<T> noHookInstanceSupplier)
        Creates a new control implementation for hooks.
        Parameters:
        self - reference to object returned by chainnable calls
        proxy - proxy object to apply hooks on
        control - control interface
        instantiator - components instantiator
        noHookInstanceSupplier - supplier of new instance without any hook.
    • Method Detail

      • getHookDefinitions

        public java.util.List<HookDefinition<?>> getHookDefinitions()
        Get hook definitions.
        Returns:
        hook definitions
      • getHookRestoreStack

        public java.util.Stack<java.util.List<HookDefinition<?>>> getHookRestoreStack()
        Get hook restore stack.
        Returns:
        hook restore stack
      • setHookRestoreStack

        public void setHookRestoreStack​(java.util.Stack<java.util.List<HookDefinition<?>>> hookRestoreStack)
        Set the hook restore stack.
        Parameters:
        hookRestoreStack - hook restore stack
      • removeHooksFromDefinitions

        public static void removeHooksFromDefinitions​(java.util.Collection<HookDefinition<?>> definitions,
                                                      java.lang.Class<? extends FluentHook>... hooksToRemove)
        Removes hooks from definitions.
        Parameters:
        definitions - hook definitions
        hooksToRemove - hooks to remove
      • restoreHooks

        public T restoreHooks()
        Description copied from interface: HookControl
        Retore hooks that were defined initially.
        Specified by:
        restoreHooks in interface HookControl<T>
        Returns:
        this object reference to chain calls
      • withHook

        public <O,​H extends FluentHook<O>> T withHook​(java.lang.Class<H> hook)
        Description copied from interface: HookControl
        Enable a hook with default options.
        Specified by:
        withHook in interface HookControl<T>
        Type Parameters:
        O - Type of the hook
        H - Type of the hook options
        Parameters:
        hook - hook class to enable
        Returns:
        this object reference to chain calls
      • withHook

        public <O,​H extends FluentHook<O>> T withHook​(java.lang.Class<H> hook,
                                                            O options)
        Description copied from interface: HookControl
        Enable a hook with given options.
        Specified by:
        withHook in interface HookControl<T>
        Type Parameters:
        O - Type of the hook
        H - Type of the hook options
        Parameters:
        hook - hook class to enable
        options - hook options to apply
        Returns:
        this object reference to chain calls
      • noHook

        public T noHook()
        Description copied from interface: HookControl
        Disable all hooks from actual element.
        Specified by:
        noHook in interface HookControl<T>
        Returns:
        this object reference to chain calls
      • noHook

        public T noHook​(java.lang.Class<? extends FluentHook>... hooks)
        Description copied from interface: HookControl
        Disable given hook from actual element.
        Specified by:
        noHook in interface HookControl<T>
        Parameters:
        hooks - hook classes to disable
        Returns:
        this object reference to chain calls
      • applyHooks

        protected void applyHooks​(java.lang.Object proxy,
                                  HookChainBuilder hookChainBuilder,
                                  java.util.List<HookDefinition<?>> hookDefinitions)
        Apply defined hooks on the proxy.
        Parameters:
        proxy - proxy
        hookChainBuilder - hook chain builder
        hookDefinitions - hook definitions
      • noHook

        public <R> R noHook​(java.util.function.Function<T,​R> function)
        Description copied from interface: HookControl
        Invoke a function with no hook.
        Specified by:
        noHook in interface HookControl<T>
        Type Parameters:
        R - return type
        Parameters:
        function - function to invoke
        Returns:
        return value of the given function
      • noHook

        public <R> R noHook​(java.lang.Class<? extends FluentHook> hook,
                            java.util.function.Function<T,​R> function)
        Description copied from interface: HookControl
        Invoke a function with no hook.
        Specified by:
        noHook in interface HookControl<T>
        Type Parameters:
        R - return type
        Parameters:
        hook - hook class to disable
        function - function to invoke
        Returns:
        return value of the given function
      • noHookInstance

        public T noHookInstance()
        Description copied from interface: HookControl
        Creates a new element locator instance with all hooks disabled.
        Specified by:
        noHookInstance in interface HookControl<T>
        Returns:
        new element locator with hook disabled.
      • noHookInstance

        public T noHookInstance​(java.lang.Class<? extends FluentHook>... hooks)
        Description copied from interface: HookControl
        Creates a new element locator instance with given hook disabled.
        Specified by:
        noHookInstance in interface HookControl<T>
        Parameters:
        hooks - hook classes to disable
        Returns:
        new element locator with hook disabled.