Class HookControlImpl<T>

java.lang.Object
io.fluentlenium.core.hook.HookControlImpl<T>
Type Parameters:
T - self type
All Implemented Interfaces:
HookControl<T>

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

    • HookControlImpl

      public HookControlImpl (T self, Object proxy, FluentControl control, ComponentInstantiator instantiator, 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 Details

    • getHookDefinitions

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

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

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

      public static void removeHooksFromDefinitions (Collection<HookDefinition<?>> definitions, 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 (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 (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 (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 (Object proxy, HookChainBuilder hookChainBuilder, List<HookDefinition<?>> hookDefinitions)
      Apply defined hooks on the proxy.
      Parameters:
      proxy - proxy
      hookChainBuilder - hook chain builder
      hookDefinitions - hook definitions
    • noHook

      public <R> R noHook (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 (Class<? extends FluentHook> hook, 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 (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.