Class ViewElementMode
java.lang.Object
com.foreach.across.modules.entity.views.ViewElementMode
Represents the mode for which a
ViewElementBuilder
is being requested. A mode is essentially represented by a string, so it is easy to add custom modes.
A mode has a single and multiple variant, in the latter the suffix _MULTIPLE is present in the mode string.
Multiple modes are mainly used on entity level to configure default element types for either a single or collection
representation of that entity.
A ViewElementMode
can optionally have child modes configured (withChildMode(String, ViewElementMode)
.
These are named sub-modes which can be used for more complex control rendering.- Author:
- Arne Vandamme
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ViewElementMode
Form control for modifying the descriptor.static final ViewElementMode
Control for filtering on the property or entity.static final ViewElementMode
Wrapper for the control for filtering on the property or entity.static final ViewElementMode
Control for detail (form) view.static final ViewElementMode
Control for modifying form view.static final ViewElementMode
Only the label text of the descriptor.static final ViewElementMode
Form control for modifying the descriptor - for use in list view (usually tabular).static final ViewElementMode
Only the label text of the descriptor - for use in list view (usually tabular).static final ViewElementMode
Only the (readonly) value of the descriptor - for use in list view (usually tabular).static final ViewElementMode
Only the (readonly) value of the descriptor. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
Converts the current mode to the multiple variant.Converts the current mode to the single variant.getChildMode
(@NonNull String childModeName) Get the child mode.getChildMode
(@NonNull String childModeName, ViewElementMode defaultIfNotSet) Get the child mode or return the default value if not set.Get the child modes attached.boolean
int
hashCode()
static boolean
isControl
(@NonNull ViewElementMode mode) boolean
static boolean
isLabel
(@NonNull ViewElementMode mode) static boolean
isList
(@NonNull ViewElementMode mode) static boolean
isValue
(@NonNull ViewElementMode mode) boolean
matchesSingleTypeOf
(ViewElementMode viewElementMode) Check if this view element mode has the same single type as the argument.boolean
matchesSingleTypeOfAny
(ViewElementMode... viewElementModes) Check if this view element mode has the same single type as any of the arguments.boolean
matchesTypeOf
(ViewElementMode viewElementMode) Check if this view element mode has the same base type as the arguments.boolean
matchesTypeOfAny
(ViewElementMode... viewElementModes) Check if this view element mode has the same base type as any of the arguments.static ViewElementMode
Parses a string into a valid mode.toString()
withChildMode
(@NonNull String childModeName, ViewElementMode viewElementMode) Creates a new element mode with the additional child mode configured.withoutChildMode
(@NonNull String childModeName) Creates a new element mode without the child mode configured.Creates a new element mode without any child modes configured.
-
Field Details
-
LABEL
Only the label text of the descriptor. -
VALUE
Only the (readonly) value of the descriptor. -
CONTROL
Form control for modifying the descriptor. -
LIST_LABEL
Only the label text of the descriptor - for use in list view (usually tabular). -
LIST_VALUE
Only the (readonly) value of the descriptor - for use in list view (usually tabular). -
LIST_CONTROL
Form control for modifying the descriptor - for use in list view (usually tabular). -
FORM_READ
Control for detail (form) view. -
FORM_WRITE
Control for modifying form view. -
FILTER_FORM
Wrapper for the control for filtering on the property or entity. Usually a form group with holds the FILTER_CONTROL. -
FILTER_CONTROL
Control for filtering on the property or entity.
-
-
Constructor Details
-
ViewElementMode
Deprecated.useof(String)
instead.
-
-
Method Details
-
toString
-
withoutChildMode
Creates a new element mode without the child mode configured.- Parameters:
childModeName
- child mode name- Returns:
- new mode instance
-
withChildMode
public ViewElementMode withChildMode(@NonNull @NonNull String childModeName, ViewElementMode viewElementMode) Creates a new element mode with the additional child mode configured. If theviewElementMode
argument isnull
, the child mode will be removed.- Parameters:
childModeName
- child mode nameviewElementMode
- mode to apply for the child mode- Returns:
- new mode instance
-
withoutChildModes
Creates a new element mode without any child modes configured.- Returns:
- new mode instance
-
forMultiple
Converts the current mode to the multiple variant. If the current mode is already a multiple (ends with _MULTIPLE), the current reference will be returned.- Returns:
- new instance or same if already a multiple
-
forSingle
Converts the current mode to the single variant. If the current mode is not a multiple variant, the current reference will be returned.- Returns:
- new instance or same if not a multiple
-
isForMultiple
public boolean isForMultiple()- Returns:
- true if this mode corresponds to multiple
-
getChildMode
Get the child mode.- Parameters:
childModeName
- name of the child mode- Returns:
- mode
- See Also:
-
hasChildModes
public boolean hasChildModes()- Returns:
- true if a child mode is set
-
getChildMode
public ViewElementMode getChildMode(@NonNull @NonNull String childModeName, ViewElementMode defaultIfNotSet) Get the child mode or return the default value if not set.- Parameters:
childModeName
- name of the child modedefaultIfNotSet
- default value- Returns:
- mode
-
matchesTypeOf
Check if this view element mode has the same base type as the arguments. This ignores any child modes set on the view element modes. This check requires the plurality to match, usematchesSingleTypeOf(ViewElementMode)
if you want to ignore the plural indicator.- Parameters:
viewElementMode
- to compare with- Returns:
- true if any element mode matches
-
matchesSingleTypeOf
Check if this view element mode has the same single type as the argument. This ignores any child modes set on the view element modes.- Parameters:
viewElementMode
- to compare with- Returns:
- true if any element mode matches
-
matchesTypeOfAny
Check if this view element mode has the same base type as any of the arguments. This ignores any child modes set on the view element modes. This check requires the plurality to match, usematchesSingleTypeOfAny(ViewElementMode...)
if you want to ignore the plural indicator.- Parameters:
viewElementModes
- to compare with- Returns:
- true if any element mode matches
-
matchesSingleTypeOfAny
Check if this view element mode has the same single type as any of the arguments. This ignores any child modes set on the view element modes.- Parameters:
viewElementModes
- to compare with- Returns:
- true if any element mode matches
-
of
Parses a string into a valid mode.- Parameters:
viewElementModeString
- representation- Returns:
- view element mode
-
isList
-
isLabel
-
isValue
-
isControl
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getChildModes
Get the child modes attached.
-
of(String)
instead.