public interface Component<C extends Component<C>> extends Serializable, Comparable<C>, Copyable<C>
This specification is a representation of the most basic component metadata. There are many extensions of this base specification that include additional properties and helper methods to create a more guided experience when building various components.
There are several core extensions of this specification that represent distinct component
classifications. View
specifications are used for representing view components.
Field
, External
, and Group
specifications all extend
FormComponent
and are used for representing different types of components rendered within
forms. Various extensions of these core specifications exist that serve as a guide when creating
metadata for more complicated components.
Modifier and Type | Method and Description |
---|---|
default C |
addAction(Action<?> action)
Adds an action using the action's ID as the key.
|
default C |
addAction(String key,
Action<?> action)
Adds an action at the given key.
|
default C |
addComponent(String key,
Component<?> component)
Primary method of adding a child component.
|
default C |
addEndpoint(Endpoint<?> endpoint)
Adds the provided endpoint to this component.
|
default C |
addEndpoint(String type,
Endpoint<?> endpoint)
Adds the provided endpoint with the given type to this component.
|
default C |
apply(Consumer<? super C> fn)
Executes the provided function with this component as an argument.
|
default C |
attribute(String key,
Object value)
Adds an attributes with the provided key and value.
|
default C |
augmentationKey(String augmentationKey)
Sets the augmentation key of this component.
|
default C |
classifier(String classifier)
Sets the classifier of this component.
|
default C |
clearConditionals()
Clears the current conditions on this component.
|
default C |
clearEndpoints()
Clears the existing set of endpoints.
|
default C |
conditional(Conditional<?>... conditionals)
Adds one or more conditions to this component.
|
default C |
conditionals(List<Conditional<?>> conditionals)
Adds one or more conditions to this component.
|
default C |
description(InternationalizedMessage description)
Sets the description message for this component.
|
default C |
description(String descriptionKey)
Sets the description message key for this component.
|
default Optional<Action<?>> |
findAction(Predicate<Action<?>> predicate)
Retrieves a single action matching the given predicate.
|
default Optional<Action<?>> |
findAction(String key)
Finds the action at the given key.
|
default List<Action<?>> |
findActions(Predicate<Action<?>> predicate)
Retrieves a list of actions matching the given predicate.
|
default Optional<Object> |
findAttribute(String key)
Finds the attribute at the given key.
|
default Optional<Component<?>> |
findComponent(Predicate<Component<?>> predicate)
Retrieves a single child component that matches the given predicate.
|
default Optional<Component<?>> |
findComponent(String key)
Finds the component stored at the given key.
|
default List<Component<?>> |
findComponents(Predicate<Component<?>> predicate)
Retrieves a list of child components that match the given predicate.
|
default Optional<Endpoint<?>> |
findEndpoint(Predicate<Endpoint<?>> predicate)
Retrieves a single endpoint matching the given predicate.
|
default Optional<Endpoint<?>> |
findEndpoint(String type)
Finds the endpoint stored at the given type.
|
default List<Endpoint<?>> |
findEndpoints(Predicate<Endpoint<?>> predicate)
Retrieves a list of endpoints that match the given predicate.
|
default Component<?> |
get(String key)
Alias for
getComponent(String) . |
default <T extends Component<T>> |
get(String key,
Class<T> clazz)
Alias for
getComponent(String, Class) . |
default Action<?> |
getAction(String key)
Returns the action at the provided key.
|
default <T extends Action<T>> |
getAction(String key,
Class<T> clazz)
Returns the action at the provided key with the given type.
|
Map<String,Action<?>> |
getActions()
A key-value map of actions used for managing the actions of this component.
|
default Collection<Action<?>> |
getActionsList()
The serializable, sorted list of actions.
|
default Object |
getAttribute(String key)
Retrieves the attribute at the given key.
|
default <A> A |
getAttribute(String key,
Class<A> clazz)
Retrieves the attribute at the given key and casts to the provided type.
|
Map<String,Object> |
getAttributes()
A key-value map used to provide additional metadata beyond the first-class properties.
|
String |
getAugmentationKey()
A unique identifier for the component within its full component tree.
|
String |
getClassifier()
An indicator of the class of components this component belongs to.
|
default Component<?> |
getComponent(String key)
Retrieves the component stored at the given key, if it exists.
|
default <T extends Component<T>> |
getComponent(String key,
Class<T> clazz)
Retrieves the component of the provided type stored at the given key, if it exists.
|
Map<String,Component<?>> |
getComponents()
A key-value map of components used for managing the children components of this component.
|
default Collection<Component<?>> |
getComponentsList()
The serializable, sorted list of children components.
|
List<Conditional<?>> |
getConditionals()
A set of conditions used to indicate when this component should be rendered.
|
InternationalizedMessage |
getDescription()
A description used for display purposes.
|
default Endpoint<?> |
getEndpoint(String type)
Retrieves the endpoint at the given type, if it exists.
|
default <T extends Endpoint<T>> |
getEndpoint(String type,
Class<T> clazz)
Retrieves the endpoint at the given key as the given type.
|
Map<String,Endpoint<?>> |
getEndpoints()
A key-value map of endpoints used for managing the endpoints of this component.
|
default Collection<Endpoint<?>> |
getEndpointsList()
The serializable list of endpoints.
|
String |
getId()
A unique identifier for the component among its siblings.
|
InternationalizedMessage |
getLabel()
A label used for display purposes.
|
Integer |
getOrder()
The absolute ordering of this component among its siblings.
|
String |
getScope()
The resource scope necessary for this component.
|
String |
getType()
An indicator of the type of this component.
|
default boolean |
hasAction(String key)
Returns whether or not an action exists at the given key.
|
default boolean |
hasAttribute(String key)
Returns whether or not the attribute at the given key exists.
|
default boolean |
hasComponent(String key)
Returns whether or not a child is stored at the given key.
|
default boolean |
hasEndpoint(String key)
Returns whether or not an endpoint exists at the given key.
|
default C |
id(String id)
Sets the id of this component.
|
default boolean |
isAugmentable()
Whether or not the component is able to be augmented.
|
boolean |
isTranslatable()
Whether or not this component deals with translatable data.
|
default C |
label(InternationalizedMessage label)
Sets the label message for this component.
|
default C |
label(String labelKey)
Sets the label message key for this component.
|
default C |
notTranslatable()
Sets this component as not translatable.
|
default C |
order(Integer order)
Sets the order for this component.
|
default C |
removeAction(String key)
Removes the action at the given key.
|
default C |
removeAttribute(String key)
Removes the attributes at the given key.
|
default C |
removeComponent(String key)
Removes the component at the given key.
|
default C |
removeEndpoint(String type)
Removes the endpoint with the given type.
|
default C |
scope(String scope)
Sets the scope for this component.
|
default C |
self()
Used internally to grab this component casted to
C . |
void |
setActions(Map<String,Action<?>> actions) |
void |
setAttributes(Map<String,Object> attributes) |
void |
setAugmentationKey(String augmentationKey) |
void |
setClassifier(String classifier) |
void |
setComponents(Map<String,Component<?>> components) |
void |
setConditionals(List<Conditional<?>> conditionals) |
void |
setDescription(InternationalizedMessage description) |
void |
setEndpoints(Map<String,Endpoint<?>> endpoints) |
void |
setId(String id) |
void |
setLabel(InternationalizedMessage label) |
void |
setOrder(Integer order) |
void |
setScope(String scope) |
void |
setTranslatable(boolean translatable) |
void |
setType(String type) |
default C |
translatable()
Sets this component as translatable.
|
default C |
translatable(boolean translatable)
Sets whether or not the component is translatable.
|
default C |
type(String type)
Sets the type of this component.
|
compareTo
@Nullable String getClassifier()
Classifiers.FIELD
is used to distinguish fields from other form components, and
fields have unique interactions available to them, such as interacting with the form state.for a list of classifiers
@Nullable String getType()
FieldTypes.STRING
for a
Classifiers.FIELD
will result in a text input for managing a property.@Nullable String getId()
@Nullable String getAugmentationKey()
default boolean isAugmentable()
@Nullable InternationalizedMessage getDescription()
@Nullable InternationalizedMessage getLabel()
@Nullable Integer getOrder()
@Nullable String getScope()
boolean isTranslatable()
List<Conditional<?>> getConditionals()
Map<String,Object> getAttributes()
Map<String,Component<?>> getComponents()
Map<String,Action<?>> getActions()
Map<String,Endpoint<?>> getEndpoints()
default Collection<Component<?>> getComponentsList()
default Collection<Action<?>> getActionsList()
default Collection<Endpoint<?>> getEndpointsList()
void setClassifier(String classifier)
void setType(String type)
void setId(String id)
void setAugmentationKey(String augmentationKey)
void setLabel(InternationalizedMessage label)
void setDescription(InternationalizedMessage description)
void setOrder(Integer order)
void setScope(String scope)
void setTranslatable(boolean translatable)
void setConditionals(List<Conditional<?>> conditionals)
default C self()
C
.default C apply(Consumer<? super C> fn)
fn
- the functiondefault C classifier(String classifier)
classifier
- the classifierdefault C type(String type)
type
- the typedefault C augmentationKey(String augmentationKey)
augmentationKey
- the augmentation keydefault C description(String descriptionKey)
descriptionKey
- the description's message key.default C description(InternationalizedMessage description)
description
- the description messagedefault C label(String labelKey)
labelKey
- the label's message key.default C label(InternationalizedMessage label)
label
- the label messagedefault C order(Integer order)
order
- the orderdefault C scope(String scope)
scope
- the scopedefault C translatable(boolean translatable)
translatable
- whether or not translatabledefault C translatable()
default C notTranslatable()
default C conditional(Conditional<?>... conditionals)
conditionals
- the condition(s)default C conditionals(List<Conditional<?>> conditionals)
conditionals
- the condition(s)default C clearConditionals()
default C attribute(String key, @Nullable Object value)
key
- the keyvalue
- the valuedefault C removeAttribute(String key)
key
- the keydefault boolean hasAttribute(String key)
key
- the keydefault Object getAttribute(String key)
key
- the keyIllegalArgumentException
- if no attribute exists at the keydefault <A> A getAttribute(String key, Class<A> clazz)
A
- the typekey
- the keyclazz
- the type of attributedefault Optional<Object> findAttribute(String key)
getAttribute(String)
.key
- the keydefault C addComponent(String key, Component<?> component)
key
- the keycomponent
- the child componentdefault C removeComponent(String key)
key
- the keydefault boolean hasComponent(String key)
key
- the keydefault Component<?> getComponent(String key)
key
- the keyIllegalArgumentException
- if no component is found with that keydefault <T extends Component<T>> T getComponent(String key, Class<T> clazz)
key
- the keyclazz
- the type of the componentIllegalArgumentException
- if no component is found with that keydefault Component<?> get(String key)
getComponent(String)
.default <T extends Component<T>> T get(String key, Class<T> clazz)
getComponent(String, Class)
.default Optional<Component<?>> findComponent(String key)
getComponent(String)
.key
- the keydefault List<Component<?>> findComponents(Predicate<Component<?>> predicate)
predicate
- the predicatedefault Optional<Component<?>> findComponent(Predicate<Component<?>> predicate)
predicate
- the predicatedefault boolean hasEndpoint(String key)
key
- the keydefault Endpoint<?> getEndpoint(String type)
type
- the typeIllegalArgumentException
- if the endpoint does not existdefault <T extends Endpoint<T>> T getEndpoint(String type, Class<T> clazz)
T
- the typetype
- the typeclazz
- the typedefault Optional<Endpoint<?>> findEndpoint(String type)
getEndpoint(String)
.type
- the keydefault List<Endpoint<?>> findEndpoints(Predicate<Endpoint<?>> predicate)
predicate
- the predicatedefault Optional<Endpoint<?>> findEndpoint(Predicate<Endpoint<?>> predicate)
predicate
- the predicatedefault C addEndpoint(Endpoint<?> endpoint)
endpoint
- the endpoint to adddefault C addEndpoint(String type, Endpoint<?> endpoint)
type
- the typeendpoint
- the endpointdefault C removeEndpoint(String type)
type
- the typedefault C clearEndpoints()
default C addAction(Action<?> action)
action
- the actiondefault C addAction(String key, Action<?> action)
key
- the keyaction
- the actiondefault C removeAction(String key)
key
- the keydefault boolean hasAction(String key)
key
- the keydefault Action<?> getAction(String key)
key
- the keyIllegalArgumentException
- if no action existsfor a null-safe get operation
default <T extends Action<T>> T getAction(String key, Class<T> clazz)
T
- the typekey
- the keyclazz
- the typedefault Optional<Action<?>> findAction(String key)
getAction(String)
.key
- the keydefault List<Action<?>> findActions(Predicate<Action<?>> predicate)
predicate
- the predicateCopyright © 2021. All rights reserved.