Package me.a8kj.util
Interface Registry<T>
- Type Parameters:
T- the type of objects maintained in this registry.
- All Known Implementing Classes:
ConfigRegistry
public interface Registry<T>
A generic contract for object registration and management.
This interface defines the standard operations for a central repository,
allowing objects of type
T to be stored and retrieved using unique string keys.- Since:
- 0.1
- Author:
- a8kj7sea
-
Method Summary
Modifier and TypeMethodDescriptionentries()Provides an iterable collection of all currently registered entries.Retrieves the object associated with the given key.booleanChecks if the registry contains an entry for the specified key.voidRegisters a value associated with a specific key.voidunregister(@NonNull String key) Removes an entry from the registry using its key.
-
Method Details
-
register
Registers a value associated with a specific key.- Parameters:
key- the unique identifier for the entry. Must not be null.value- the object to be registered. Must not be null.
-
unregister
Removes an entry from the registry using its key.- Parameters:
key- the unique identifier of the entry to be removed. Must not be null.
-
hasEntry
Checks if the registry contains an entry for the specified key.- Parameters:
key- the identifier to check. Must not be null.- Returns:
trueif an entry exists,falseotherwise.
-
get
Retrieves the object associated with the given key.- Parameters:
key- the unique identifier of the entry. Must not be null.- Returns:
- the registered object of type
T.
-
entries
Provides an iterable collection of all currently registered entries. Each entry is returned as aPaircontaining the key and the object.- Returns:
- an iterable of key-value pairs.
-