Package org.apache.juneau.console
Class ModelBlock
java.lang.Object
org.apache.juneau.console.ModelBlock
The model block of one element: handler actions, lifecycle bindings and handler subscriptions.
Builders that implement Handled own one of these. Every mutator validates at once and throws
IllegalArgumentException naming the element. These checks duplicate the client rules, which are the authority.
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds an action.Returns the actions in insertion order.addAll(ModelBlock other) Appends every entry of another block to this one.Returns the element id.booleanReturns whether any entry uses an inline handler.booleanisEmpty()Returns whether the block holds nothing.kind()Returns the element kind.on(String event, HandlerRef handler) Binds a lifecycle event.subscribe(String topic, HandlerRef handler) Subscribes a handler to a bus topic.toMap()Serializes to the contractmodelobject.voidvalidate()Re-checks the whole block.
-
Constructor Details
-
ModelBlock
Creates a block.- Parameters:
kind- The element kind: page, card, table, row, rowdetail, detailtab, ribbonitem, pagetab, view or chart.elementId- The element id, used in messages.- Throws:
IllegalArgumentException- If the kind is unknown.
-
-
Method Details
-
action
Adds an action.- Parameters:
a- The action; must have a handler.- Returns:
- This object.
- Throws:
IllegalArgumentException- If the kind takes no actions, the id repeats, or no handler is set.
-
on
Binds a lifecycle event.- Parameters:
event- A documented event of this kind.handler- The handler.- Returns:
- This object.
- Throws:
IllegalArgumentException- If the event is not documented for this kind.
-
subscribe
Subscribes a handler to a bus topic.- Parameters:
topic- A topic; the key may hold{rowKey},{tabId}or{cardId}where this kind provides them.handler- The handler.- Returns:
- This object.
- Throws:
IllegalArgumentException- If the topic is invalid or a template is not available here.
-
validate
Re-checks the whole block.- Throws:
IllegalArgumentException- If any entry is invalid.
-
addAll
Appends every entry of another block to this one.- Parameters:
other- The block to copy from.- Returns:
- This object.
-
isEmpty
Returns whether the block holds nothing.- Returns:
true if empty.
-
hasInline
Returns whether any entry uses an inline handler.- Returns:
true if an inline reference is present.
-
actionMaps
Returns the actions in insertion order.- Returns:
- The actions, as contract maps.
-
elementId
Returns the element id.- Returns:
- The id.
-
kind
Returns the element kind.- Returns:
- The kind.
-
toMap
Serializes to the contractmodelobject.- Returns:
- The map, or
null when empty so that builders not using the model emit unchanged JSON.
-