Interface ViewElement
- All Known Subinterfaces:
ConfigurableTextViewElement
,HtmlViewElement
,MutableViewElement
- All Known Implementing Classes:
AbstractNodeViewElement
,AbstractTextNodeViewElement
,AbstractVoidNodeViewElement
,ContainerViewElement
,NodeViewElement
,TemplateViewElement
,TextViewElement
,ViewElementGenerator
,ViewElementSupport
,VoidNodeViewElement
public interface ViewElement
Represents a
ViewElement
in its most simple form. In a web context this is almost certainly
a HTML node or collection thereof.- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
ViewElement.Wither<T extends ViewElement>
A wrapper for any type ofViewElement
which allows the use of separate functions to perform the actions.static interface
ViewElement.WitherGetter<T extends ViewElement,
U> Function that fetches a value from a view element and optionally returns it as a specific type for compile time checking.static interface
ViewElement.WitherRemover<T extends ViewElement>
Function that modifies a view element by removing values.static interface
ViewElement.WitherSetter<T extends ViewElement>
Function that modifies a view element by setting or adding values. -
Method Summary
Modifier and TypeMethodDescriptiondefault <U> U
get
(ViewElement.WitherGetter<?, U> function) Get a value from the element.getName()
A ViewElement can have an internal name that identifies it within aContainerViewElement
.default boolean
Check if the element matches the predicate given.static <U extends ViewElement>
Predicate<U>predicateFor
(Class<U> elementType, Predicate<U> predicate) Short-hand for creating an anonymous typed predicate, can be used to inline type predicate creation.default ViewElement
remove
(ViewElement.WitherRemover... functions) Execute one or more remover functions.default ViewElement
set
(ViewElement.WitherSetter... setters) Execute one or more setter functions.static <U extends ViewElement>
ViewElement.Wither<U>with
(U element) Create aViewElement.Wither
wrapper for an element, which allows for a more descriptive, fluent configuration approach by using pre-defined lambdas.
-
Method Details
-
getName
String getName()A ViewElement can have an internal name that identifies it within aContainerViewElement
. A name is optional but when given, is preferably unique within its container as most operations work on the first element with a specific name.- Returns:
- Internal name of this element, can be null.
- See Also:
-
getElementType
String getElementType()- Returns:
- Type id of this view element.
-
getCustomTemplate
String getCustomTemplate()- Returns:
- Custom template to use when rendering this view element.
-
set
Execute one or more setter functions.- Parameters:
setters
- 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
-
matches
Check if the element matches the predicate given. Note there is no compiler type-safety on this method, predicate implementations should do the type checking. See alsopredicateFor(Class, Predicate)
for a helper function to create a typed predicate inline.- Parameters:
predicate
- to test- Returns:
- predicate outcome
-
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
-
with
Create aViewElement.Wither
wrapper for an element, which allows for a more descriptive, fluent configuration approach by using pre-defined lambdas.- Type Parameters:
U
- type of the element- Parameters:
element
- to create a wrapper for- Returns:
- wither
-
predicateFor
static <U extends ViewElement> Predicate<U> predicateFor(Class<U> elementType, Predicate<U> predicate) Short-hand for creating an anonymous typed predicate, can be used to inline type predicate creation.
-