Package io.fluentlenium.core.hook
Class HookControlImpl<T>
java.lang.Object
io.fluentlenium.core.hook.HookControlImpl<T>
- Type Parameters:
T
- self type
- All Implemented Interfaces:
HookControl<T>
Control implementation for hooks.
-
Constructor Summary
ConstructorsConstructorDescriptionHookControlImpl
(T self, Object proxy, FluentControl control, ComponentInstantiator instantiator, Supplier<T> noHookInstanceSupplier) Creates a new control implementation for hooks. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyHooks
(Object proxy, HookChainBuilder hookChainBuilder, List<HookDefinition<?>> hookDefinitions) Apply defined hooks on the proxy.List<HookDefinition<?>>
Get hook definitions.Stack<List<HookDefinition<?>>>
Get hook restore stack.noHook()
Disable all hooks from actual element.noHook
(Class<? extends FluentHook>... hooks) Disable given hook from actual element.<R> R
noHook
(Class<? extends FluentHook> hook, Function<T, R> function) Invoke a function with no hook.<R> R
Invoke a function with no hook.Creates a new element locator instance with all hooks disabled.noHookInstance
(Class<? extends FluentHook>... hooks) Creates a new element locator instance with given hook disabled.static void
removeHooksFromDefinitions
(Collection<HookDefinition<?>> definitions, Class<? extends FluentHook>... hooksToRemove) Removes hooks from definitions.Retore hooks that were defined initially.void
setHookRestoreStack
(Stack<List<HookDefinition<?>>> hookRestoreStack) Set the hook restore stack.<O,
H extends FluentHook<O>>
TEnable a hook with default options.<O,
H extends FluentHook<O>>
TEnable a hook with given options.
-
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 callsproxy
- proxy object to apply hooks oncontrol
- control interfaceinstantiator
- components instantiatornoHookInstanceSupplier
- supplier of new instance without any hook.
-
-
Method Details
-
getHookDefinitions
Get hook definitions.- Returns:
- hook definitions
-
getHookRestoreStack
Get hook restore stack.- Returns:
- hook restore stack
-
setHookRestoreStack
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 definitionshooksToRemove
- hooks to remove
-
restoreHooks
Description copied from interface:HookControl
Retore hooks that were defined initially.- Specified by:
restoreHooks
in interfaceHookControl<T>
- Returns:
- this object reference to chain calls
-
withHook
Description copied from interface:HookControl
Enable a hook with default options.- Specified by:
withHook
in interfaceHookControl<T>
- Type Parameters:
O
- Type of the hookH
- Type of the hook options- Parameters:
hook
- hook class to enable- Returns:
- this object reference to chain calls
-
withHook
Description copied from interface:HookControl
Enable a hook with given options.- Specified by:
withHook
in interfaceHookControl<T>
- Type Parameters:
O
- Type of the hookH
- Type of the hook options- Parameters:
hook
- hook class to enableoptions
- hook options to apply- Returns:
- this object reference to chain calls
-
noHook
Description copied from interface:HookControl
Disable all hooks from actual element.- Specified by:
noHook
in interfaceHookControl<T>
- Returns:
- this object reference to chain calls
-
noHook
Description copied from interface:HookControl
Disable given hook from actual element.- Specified by:
noHook
in interfaceHookControl<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
- proxyhookChainBuilder
- hook chain builderhookDefinitions
- hook definitions
-
noHook
Description copied from interface:HookControl
Invoke a function with no hook.- Specified by:
noHook
in interfaceHookControl<T>
- Type Parameters:
R
- return type- Parameters:
function
- function to invoke- Returns:
- return value of the given function
-
noHook
Description copied from interface:HookControl
Invoke a function with no hook.- Specified by:
noHook
in interfaceHookControl<T>
- Type Parameters:
R
- return type- Parameters:
hook
- hook class to disablefunction
- function to invoke- Returns:
- return value of the given function
-
noHookInstance
Description copied from interface:HookControl
Creates a new element locator instance with all hooks disabled.- Specified by:
noHookInstance
in interfaceHookControl<T>
- Returns:
- new element locator with hook disabled.
-
noHookInstance
Description copied from interface:HookControl
Creates a new element locator instance with given hook disabled.- Specified by:
noHookInstance
in interfaceHookControl<T>
- Parameters:
hooks
- hook classes to disable- Returns:
- new element locator with hook disabled.
-