Interface ComponentRegistry<R extends ComponentRegistry<R>>
- All Known Implementing Classes:
AbstractComponentRegistry,DefaultComponentRegistry,DevelopmentComponentRegistry
public interface ComponentRegistry<R extends ComponentRegistry<R>>
A singleton registry used for storing and retrieving
Components.- Author:
- Nick Crum (ncrum)
-
Method Summary
Modifier and TypeMethodDescriptiondefault RAlias foraddComponent(String, Component).default RAlias foraddComponent(String, Component).addComponent(String id, Component<?> component) Adds a component to the registry.default Component<?>Alias forgetComponent(String).default <T extends Component<T>>
TAlias forgetComponent(String, Class).Component<?>getComponent(String id) Retrieves a component from the registry.default <T extends Component<T>>
TgetComponent(String id, Class<T> clazz) Gets a component from the registry and casts it to the specified type.Gets all components in the registry.default booleanAlias forhasComponent(String).booleanhasComponent(String id) Checks if a component exists in the registry.default RAlias forremoveComponent(String).Removes a component from the registry.default voidRe-registers all metadata components.
-
Method Details
-
addComponent
Adds a component to the registry.- Parameters:
id- The id of the componentcomponent- The component to add- Returns:
- The registry
-
add
Alias foraddComponent(String, Component).- Parameters:
id- The id of the componentcomponent- The component to add- Returns:
- The registry
-
add
Alias foraddComponent(String, Component). UsesComponent.getId()as the id.- Parameters:
component- The component to add- Returns:
- The registry
-
removeComponent
Removes a component from the registry.- Parameters:
id- The id of the component- Returns:
- The registry
-
remove
Alias forremoveComponent(String).- Parameters:
id- The id of the component- Returns:
- The registry
-
hasComponent
Checks if a component exists in the registry.- Parameters:
id- The id of the component- Returns:
- True if the component exists, false otherwise.
-
has
Alias forhasComponent(String).- Parameters:
id- The id of the component- Returns:
- True if the component exists, false otherwise.
-
getComponent
Retrieves a component from the registry.- Parameters:
id- The id of the component- Returns:
- The component
-
get
Alias forgetComponent(String).- Parameters:
id- The id of the component- Returns:
- The component
-
getComponent
Gets a component from the registry and casts it to the specified type.- Type Parameters:
T- The type of the component to cast to- Parameters:
id- The id of the componentclazz- The class of the component- Returns:
- The component cast to the specified type.
-
get
Alias forgetComponent(String, Class).- Type Parameters:
T- The type of the component to cast to- Parameters:
id- The id of the componentclazz- The class of the component- Returns:
- The component cast to the specified type.
-
getComponents
Gets all components in the registry.- Returns:
- A map of all components in the registry, keyed by their id.
-
reRegisterComponents
default void reRegisterComponents()Re-registers all metadata components. Useful during development, as this avoids needing to restart the application.
-