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 Details

    • addComponent

      R addComponent(String id, Component<?> component)
      Adds a component to the registry.
      Parameters:
      id - The id of the component
      component - The component to add
      Returns:
      The registry
    • add

      default R add(String id, @NonNull @NonNull Component<?> component)
      Parameters:
      id - The id of the component
      component - The component to add
      Returns:
      The registry
    • add

      default R add(@NonNull @NonNull Component<?> component)
      Parameters:
      component - The component to add
      Returns:
      The registry
    • removeComponent

      R removeComponent(String id)
      Removes a component from the registry.
      Parameters:
      id - The id of the component
      Returns:
      The registry
    • remove

      default R remove(String id)
      Parameters:
      id - The id of the component
      Returns:
      The registry
    • hasComponent

      boolean hasComponent(String id)
      Checks if a component exists in the registry.
      Parameters:
      id - The id of the component
      Returns:
      True if the component exists, false otherwise.
    • has

      default boolean has(String id)
      Parameters:
      id - The id of the component
      Returns:
      True if the component exists, false otherwise.
    • getComponent

      Component<?> getComponent(String id)
      Retrieves a component from the registry.
      Parameters:
      id - The id of the component
      Returns:
      The component
    • get

      default Component<?> get(String id)
      Parameters:
      id - The id of the component
      Returns:
      The component
    • getComponent

      default <T extends Component<T>> T getComponent(String id, Class<T> clazz)
      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 component
      clazz - The class of the component
      Returns:
      The component cast to the specified type.
    • get

      default <T extends Component<T>> T get(String id, Class<T> clazz)
      Type Parameters:
      T - The type of the component to cast to
      Parameters:
      id - The id of the component
      clazz - The class of the component
      Returns:
      The component cast to the specified type.
    • getComponents

      Map<String,Component<?>> 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.