Interface CardTypeHandler
- All Known Implementing Classes:
ChartCardType,DatatablesCardType,HtmlCardType,InventoryGaugeCardType,JobLogCardType,TerminalCardType
type() renders the fragment.
A type with no registered handler uses the generic passthrough (JSON5 body becomes the fragment, markup body becomes a template), so most custom cards need only JS. Register a handler when the server must validate or enrich the body.
Example:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptioncmd:<id>ops this type handles, beyond the shell'srefresh, for E-43 on a ribbontarget.Roles this type accepts insubscribes[].as, beyondrefreshandparams.implicitTopics(JsonMap card) Topics this card publishes without declaring them, for R-10.requiredPacks(JsonMap body) Toolkit packs this card needs because of what its body declares, beyond the packs its type always needs.toFragment(CardSource source) Validates the authored card and returns its contract fragment.type()The type name this handler serves.
-
Method Details
-
type
The type name this handler serves.- Returns:
- The type name; must match
^[a-z][a-z0-9-]{0,31}$(E-21).
-
toFragment
Validates the authored card and returns its contract fragment.- Parameters:
source- The authored card (attributes plus body).- Returns:
- The fragment merged flat onto the card's base keys; must not contain a reserved key (E-23).
- Throws:
IllegalArgumentException- viaCardSource.error(String, Object...)on invalid input.
-
implicitTopics
Topics this card publishes without declaring them, for R-10. Default: none (the shell adds card:/cmd:).Example:
@Override public List<String> implicitTopics(JsonMapcard ) {return List.of ("kpi.threshold-crossed" ); }- Parameters:
card- The card object from the page contract (base keys plus this type's fragment).- Returns:
- The concrete topics (or
ns.name:*patterns) the type's JS publishes for this card.
-
acceptedRoles
Roles this type accepts insubscribes[].as, beyondrefreshandparams.null(the default) means "unknown to Java": the Java validator skips E-44 and the JS check (E-JS-47) decides.Example:
@Override public Set<String> acceptedRoles() {return Set.of ("highlight" ); }- Returns:
- The accepted role names, or
nullif unknown.
-
acceptedOps
cmd:<id>ops this type handles, beyond the shell'srefresh, for E-43 on a ribbontarget.null(the default) means "unknown to Java": the Java validator skips the check and the JS shell reports an unhandled op at runtime (E-JS-48).Example:
@Override public Set<String> acceptedOps() {return Set.of ("set-target" ); }- Returns:
- The handled op names, or
nullif unknown.
-
requiredPacks
Toolkit packs this card needs because of what its body declares, beyond the packs its type always needs. Unioned with the type's packs and the card'srequires=. Default: none.Example:
@Override public List<String> requiredPacks(JsonMapbody ) {return body .containsKey("terminal" ) ? List.of ("terminal" ) : List.of (); }- Parameters:
body- The card's body: this type's fragment, astoFragment(CardSource)returned it.- Returns:
- The pack names; each must be a registered pack.
-