Package me.a8kj.config.template.registry
Class ConfigRegistry
java.lang.Object
me.a8kj.config.template.registry.ConfigRegistry
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull Iterable<Pair<String, ConfigFile<?>>> entries()Returns an iterable collection of all registered entries asPairobjects.@NonNull ConfigFile<?> Retrieves a registered configuration file.booleanChecks if a specific key is already registered.voidregister(@NonNull String key, @NonNull ConfigFile<?> value) Registers a configuration file with a unique identifying key.voidunregister(@NonNull String key) Removes a configuration from the registry.
-
Constructor Details
-
ConfigRegistry
public ConfigRegistry()
-
-
Method Details
-
register
Registers a configuration file with a unique identifying key.- Specified by:
registerin interfaceRegistry<ConfigFile<?>>- Parameters:
key- the unique identifier for the config.value- the configuration file instance.
-
unregister
Removes a configuration from the registry.- Specified by:
unregisterin interfaceRegistry<ConfigFile<?>>- Parameters:
key- the identifier of the config to remove.
-
hasEntry
Checks if a specific key is already registered.- Specified by:
hasEntryin interfaceRegistry<ConfigFile<?>>- Parameters:
key- the key to check.- Returns:
trueif present,falseotherwise.
-
get
Retrieves a registered configuration file.- Specified by:
getin interfaceRegistry<ConfigFile<?>>- Parameters:
key- the identifier for the config.- Returns:
- the
ConfigFileinstance. - Throws:
NullPointerException- if no config is found for the given key.
-
entries
Returns an iterable collection of all registered entries asPairobjects.- Specified by:
entriesin interfaceRegistry<ConfigFile<?>>- Returns:
- an iterable of key-config pairs.
-