Package org.fluentlenium.core.hook
Class HookControlImpl<T>
- java.lang.Object
-
- org.fluentlenium.core.hook.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 Summary
Constructors Constructor Description HookControlImpl(T self, java.lang.Object proxy, FluentControl control, ComponentInstantiator instantiator, java.util.function.Supplier<T> noHookInstanceSupplier)
Creates a new control implementation for hooks.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyHooks(java.lang.Object proxy, HookChainBuilder hookChainBuilder, java.util.List<HookDefinition<?>> hookDefinitions)
Apply defined hooks on the proxy.java.util.List<HookDefinition<?>>
getHookDefinitions()
Get hook definitions.java.util.Stack<java.util.List<HookDefinition<?>>>
getHookRestoreStack()
Get hook restore stack.T
noHook()
Disable all hooks from actual element.T
noHook(java.lang.Class<? extends FluentHook>... hooks)
Disable given hook from actual element.<R> R
noHook(java.lang.Class<? extends FluentHook> hook, java.util.function.Function<T,R> function)
Invoke a function with no hook.<R> R
noHook(java.util.function.Function<T,R> function)
Invoke a function with no hook.T
noHookInstance()
Creates a new element locator instance with all hooks disabled.T
noHookInstance(java.lang.Class<? extends FluentHook>... hooks)
Creates a new element locator instance with given hook disabled.static void
removeHooksFromDefinitions(java.util.Collection<HookDefinition<?>> definitions, java.lang.Class<? extends FluentHook>... hooksToRemove)
Removes hooks from definitions.T
restoreHooks()
Retore hooks that were defined initially.void
setHookRestoreStack(java.util.Stack<java.util.List<HookDefinition<?>>> hookRestoreStack)
Set the hook restore stack.<O,H extends FluentHook<O>>
TwithHook(java.lang.Class<H> hook)
Enable a hook with default options.<O,H extends FluentHook<O>>
TwithHook(java.lang.Class<H> hook, O options)
Enable a hook with given options.
-
-
-
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 callsproxy
- proxy object to apply hooks oncontrol
- control interfaceinstantiator
- components instantiatornoHookInstanceSupplier
- 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 definitionshooksToRemove
- hooks to remove
-
restoreHooks
public T 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
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 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
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 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
public T 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
public T noHook(java.lang.Class<? extends FluentHook>... hooks)
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(java.lang.Object proxy, HookChainBuilder hookChainBuilder, java.util.List<HookDefinition<?>> hookDefinitions)
Apply defined hooks on the proxy.- Parameters:
proxy
- proxyhookChainBuilder
- hook chain builderhookDefinitions
- 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 interfaceHookControl<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 interfaceHookControl<T>
- Type Parameters:
R
- return type- Parameters:
hook
- hook class to disablefunction
- 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 interfaceHookControl<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 interfaceHookControl<T>
- Parameters:
hooks
- hook classes to disable- Returns:
- new element locator with hook disabled.
-
-