Class SwitcherDef
java.lang.Object
org.apache.juneau.console.freemarker.SwitcherDef
Builder for a
switcher card: one card slot that shows one of several named views, each holding one card or a
strip of sections that each hold a card.
A view with a single section that has the default id and no model block serializes as a plain card; any
other view serializes as sections. A switcher cannot hold another switcher. Validation runs in
toCardSpec() and is shared with SwitcherCardType through validate(String, Map), so both
paths report the same messages.
Example:
CardSpec
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOne section of a switcher view.static final classOne view of a switcher. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic SwitcherDefinitialView(String viewId) Builds theswitchercard entry.static voidValidates a switcher body: the shape the builder emits and the page-contract JSON carries.static voidvalidateStyle(String id, Object v) Validates a switcher style token.view(String viewId, String label, Consumer<SwitcherDef.View> config) Adds a view.
-
Field Details
-
STYLE_TABS
The default switcher style: a folder-tab strip joined to the display.- See Also:
-
STYLE_SLIDER
The segmented-control style: a pill track with a sliding thumb.- See Also:
-
-
Method Details
-
create
- Parameters:
id- The card id. @return A new switcher.
-
title
- Parameters:
v- The card title. @return This object.
-
style
- Parameters:
v- The switcher style,STYLE_TABS(default) orSTYLE_SLIDER. @return This object.
-
validateStyle
Validates a switcher style token.- Parameters:
id- The switcher id, used in the message.v- The style, ornull for the default.- Throws:
IllegalArgumentException- If the value is neitherSTYLE_TABSnorSTYLE_SLIDER.
-
initialView
- Parameters:
viewId- The id of the view shown first when nothing else decides. @return This object.
-
view
Adds a view.- Parameters:
viewId- The view id, matching[A-Za-z][A-Za-z0-9_-]{0,63}.label- The tab label.config- Fills in the view's sections and model block.- Returns:
- This object.
-
toCardSpec
Builds theswitchercard entry.- Returns:
- The card.
- Throws:
IllegalArgumentException- If the switcher is invalid.
-
validate
Validates a switcher body: the shape the builder emits and the page-contract JSON carries.- Parameters:
id- The switcher id, used in messages.body- The body holdingviewsand optionallyinitialView.- Throws:
IllegalArgumentException- On the first problem found.
-