Class ConfigRegistry

java.lang.Object
me.a8kj.config.template.registry.ConfigRegistry
All Implemented Interfaces:
Registry<ConfigFile<?>>

public class ConfigRegistry extends Object implements Registry<ConfigFile<?>>
A thread-safe registry for managing ConfigFile instances. This class acts as a central repository, allowing developers to register, retrieve, and iterate over all configuration files used in the application.
Since:
0.1
Author:
a8kj7sea
  • Constructor Details

    • ConfigRegistry

      public ConfigRegistry()
  • Method Details

    • register

      public void register(@NonNull @NonNull String key, @NonNull @NonNull ConfigFile<?> value)
      Registers a configuration file with a unique identifying key.
      Specified by:
      register in interface Registry<ConfigFile<?>>
      Parameters:
      key - the unique identifier for the config.
      value - the configuration file instance.
    • unregister

      public void unregister(@NonNull @NonNull String key)
      Removes a configuration from the registry.
      Specified by:
      unregister in interface Registry<ConfigFile<?>>
      Parameters:
      key - the identifier of the config to remove.
    • hasEntry

      public boolean hasEntry(@NonNull @NonNull String key)
      Checks if a specific key is already registered.
      Specified by:
      hasEntry in interface Registry<ConfigFile<?>>
      Parameters:
      key - the key to check.
      Returns:
      true if present, false otherwise.
    • get

      @NonNull public @NonNull ConfigFile<?> get(@NonNull @NonNull String key)
      Retrieves a registered configuration file.
      Specified by:
      get in interface Registry<ConfigFile<?>>
      Parameters:
      key - the identifier for the config.
      Returns:
      the ConfigFile instance.
      Throws:
      NullPointerException - if no config is found for the given key.
    • entries

      @NonNull public @NonNull Iterable<Pair<String,ConfigFile<?>>> entries()
      Returns an iterable collection of all registered entries as Pair objects.
      Specified by:
      entries in interface Registry<ConfigFile<?>>
      Returns:
      an iterable of key-config pairs.