Interface Registry<R extends RegistryKey,T>
- Type Parameters:
R- the type of the registry key, extendingRegistryKey.T- the type of the values stored in the registry.
- All Superinterfaces:
Iterable<T>
- All Known Subinterfaces:
NamespacedRegistry<T>
- All Known Implementing Classes:
AbstractRegistry,AbstractRegistry.Identified,AbstractRegistry.Namespaced,SocialRegistries.Channels
The
Registry interface represents a generic registry for storing and managing a collection of
values, which are associated with keys that implement the RegistryKey interface.
Registries provide a way to store, retrieve, and manipulate objects based on their unique keys.
The registry can store any type of object that is mapped to a particular key type R, which
extends RegistryKey. Implementations of this interface will define specific behaviors for
managing the registry, including registration, unregistration, and key-based lookups.
It provides methods for:
- Registering objects to the registry
- Unregistering objects
- Checking if a key or value exists
- Retrieving values associated with keys
- Retrieving values by their type
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(R registryKey) Checks if a value exists in the registry for the given registry key.booleancontainsValue(T value) Checks if a given value exists in the registry.static <T> Registry<IdentifiedRegistryKey, T> identified(@NotNull Class<T> type) Creates and returns a registry that usesIdentifiedRegistryKeyas the key type.keys()Retrieves a set of all the registry keys in the registry.static <T> NamespacedRegistry<T> namespaced(@NotNull Class<T> type) Creates and returns a registry that usesNamespacedRegistryKeyas the key type.voidRegisters a value to the registry, associating it with the given registry key.registry()Retrieves the underlying map of the registry, where the keys are the registry keys and the values are the associated objects.unregister(R registryKey) Unregisters a value from the registry, removing it associated with the given registry key.Retrieves the value associated with the given registry key, wrapped in anOptional.values()Retrieves a list of all the values in the registry.valuesByType(@NotNull Class<V> type) Retrieves a list of values of a specific type associated with the registry.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
identified
Creates and returns a registry that usesIdentifiedRegistryKeyas the key type.- Type Parameters:
T- the type of the values.- Parameters:
type- the type of the values stored in the registry.- Returns:
- a registry that uses identified keys.
-
namespaced
Creates and returns a registry that usesNamespacedRegistryKeyas the key type.- Type Parameters:
T- the type of the values.- Parameters:
type- the type of the values stored in the registry.- Returns:
- a registry that uses namespaced keys.
-
registry
Retrieves the underlying map of the registry, where the keys are the registry keys and the values are the associated objects.- Returns:
- a
Mapwhere keys are registry keys and values are the registry values.
-
register
Registers a value to the registry, associating it with the given registry key.- Parameters:
registryKey- the key to associate with the value.value- the value to register.
-
unregister
Unregisters a value from the registry, removing it associated with the given registry key.- Parameters:
registryKey- the key whose associated value should be removed.- Returns:
- the removed value, or
nullif no value was associated with the key.
-
containsKey
Checks if a value exists in the registry for the given registry key.- Parameters:
registryKey- the key to check.- Returns:
trueif the key exists in the registry,falseotherwise.
-
containsValue
Checks if a given value exists in the registry.- Parameters:
value- the value to check.- Returns:
trueif the value exists in the registry,falseotherwise.
-
value
Retrieves the value associated with the given registry key, wrapped in anOptional. -
valuesByType
Retrieves a list of values of a specific type associated with the registry.- Type Parameters:
V- the type of the values to retrieve.- Parameters:
type- the class type of the values to retrieve.- Returns:
- a list of values that match the given type.
-
keys
Retrieves a set of all the registry keys in the registry.- Returns:
- a
Setof registry keys.
-
values
Retrieves a list of all the values in the registry.- Returns:
- a
Listof all values in the registry.
-