Package net.paulem.arcana.registry
Class AbstractRegistry<T extends RegistryKey<K>,K>
java.lang.Object
net.paulem.arcana.registry.AbstractRegistry<T,K>
- Type Parameters:
T- the type
- All Implemented Interfaces:
Registry<T,K>
- Direct Known Subclasses:
FrozenRegistry,WriteableRegistry
public abstract class AbstractRegistry<T extends RegistryKey<K>,K>
extends Object
implements Registry<T,K>
A basic abstract implementation of Registry
- Since:
- 1.0.0-SNAPSHOT
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRegistry(Supplier<Map<K, T>> registrySupplier) Creates a new registry backed by the map produced by the given supplier. -
Method Summary
Modifier and TypeMethodDescriptionFetches an entry from the registrygetOrDefault(K key, @NotNull Supplier<T> defaultValue) Fetches the value at the given key or a provided default keygetOrDefault(K key, T defaultValue) Fetches the value at the given key or a provided default keyFetches an entry from the registrygetOrThrow(K key) Fetches an entry from the registry using the specified key or throws an exception if no entry exists.keys()Retrieves a set of all keys from the registry
-
Field Details
-
registry
-
-
Constructor Details
-
AbstractRegistry
Creates a new registry backed by the map produced by the given supplier.- Parameters:
registrySupplier- supplies the backing map used to store registered objects
-
-
Method Details
-
get
Fetches an entry from the registry -
getOrNull
Fetches an entry from the registry -
getOrDefault
Fetches the value at the given key or a provided default key- Specified by:
getOrDefaultin interfaceRegistry<T extends RegistryKey<K>,K> - Parameters:
key- the keydefaultValue- the default value given the key has no value- Returns:
- a non null value from either the key or default
-
getOrDefault
Fetches the value at the given key or a provided default key- Specified by:
getOrDefaultin interfaceRegistry<T extends RegistryKey<K>,K> - Parameters:
key- the keydefaultValue- the default value function triggered if the key has no value- Returns:
- a non null value from either the key or default
-
getOrThrow
Fetches an entry from the registry using the specified key or throws an exception if no entry exists.- Specified by:
getOrThrowin interfaceRegistry<T extends RegistryKey<K>,K> - Parameters:
key- the key to fetch the entry from the registry- Returns:
- the entry corresponding to the specified key
-
keys
Retrieves a set of all keys from the registry
-