Class ViewElement.Wither<T extends ViewElement>
java.lang.Object
com.foreach.across.modules.web.ui.ViewElement.Wither<T>
- Type Parameters:
T
- type of the view element
- Enclosing interface:
- ViewElement
A wrapper for any type of
ViewElement
which allows the use of separate
functions to perform the actions. Uses 3 separate functional interfaces to perform
typical actions and convey meaning (get, set, remove).
The main purpose of the wither approach is to allow a library of functions to be
defined that allow a more descriptive and fluent approach of configuration elements.
Using separate functions increases testability and removes the need for a complex class hierarchy.
Default functions are available for typical html node actions.
Because of limitations with generics, the wither does not define a type on its parameter interfaces.
This means that the function implementations should do type checking at runtime where appropriate,
or runtime class cast exceptions will be thrown.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAllows for a specifically typed generic consumer to be passed or defined.get()
<U> U
get
(ViewElement.WitherGetter<?, U> function) Get a value from the element.remove
(ViewElement.WitherRemover... functions) Execute one or more remover functions.set
(ViewElement.WitherSetter... setters) Execute one or more setter functions.
-
Constructor Details
-
Wither
-
-
Method Details
-
set
Execute one or more setter functions.- Parameters:
setters
- to execute- Returns:
- self
-
apply
Allows for a specifically typed generic consumer to be passed or defined.- Parameters:
consumer
- to execute- Returns:
- self
-
remove
Execute one or more remover functions. A remover is defined as a separate interface so implementations can both implement setter and remover at the same time.- Parameters:
functions
- to execute- Returns:
- self
-
get
Get a value from the element. UseViewElement.WitherGetter.as(Class)
for compile time typing. Note that runtime type casting execptions will occur when using the wrong type.- Type Parameters:
U
- type of the expected return value- Parameters:
function
- that returns the value- Returns:
- value
-
get
-