public class BaseRegistry extends java.lang.Object implements Registry
| Constructor and Description |
|---|
BaseRegistry() |
| Modifier and Type | Method and Description |
|---|---|
<T> void |
addToCollection(Key<? extends java.util.Collection<T>> key,
T value)
Adds the provided value to this registry's
Collection value for the provided Key |
<T> java.util.Optional<T> |
get(Key<T> key)
Gets this registry's value for the provided
Key
or Optional.empty() if it is not present. |
<T> T |
getDefault(Key<T> key)
Gets this registry's default value for the provided
Key
or the fallback value if it is not present. |
<T> T |
getUnsafe(Key<T> key)
Gets this registry's value for the provided
Key
and throws an exception if it is not present. |
void |
load()
Runs all
listeners that were
added before this call. |
<K,T> void |
putInMap(Key<? extends java.util.Map<K,T>> key,
K mapKey,
T mapValue)
Puts the provided key and value pair to this registry's
Map value for the provided Key |
<T> void |
remove(Key<T> key)
Removes this registry's value for the provided
Key |
<T> void |
removeFromCollection(Key<? extends java.util.Collection<T>> key,
T value)
Removes the provided value from this registry's
Collection value for the provided Key |
<K,T> void |
removeFromMap(Key<? extends java.util.Map<K,T>> key,
K mapKey)
Removes the provided key from this registry's
Map value for the provided Key |
<T> void |
set(Key<T> key,
T value)
Sets this registry's value for the provided
Key |
protected <T> void |
setDefault(Key<T> key,
T value) |
java.lang.String |
toString() |
<T> void |
transform(Key<T> key,
java.util.function.BiFunction<? super Key<T>,? super T,? extends T> transformer)
Applies the provided transformation to this registry's
value for the provided
Key |
<T> void |
transform(Key<T> key,
java.util.function.Function<? super T,? extends T> transformer)
Applies the provided transformation to this registry's
value for the provided
Key |
void |
whenLoaded(java.lang.Runnable listener)
Adds a
Runnable to be loaded on Registry.load() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetOrDefaultpublic <T> T getUnsafe(Key<T> key)
RegistryKey
and throws an exception if it is not present.public <T> java.util.Optional<T> get(Key<T> key)
RegistryKey
or Optional.empty() if it is not present.public <T> T getDefault(Key<T> key)
RegistryKey
or the fallback value if it is not present.getDefault in interface RegistryT - The value type of the provided Keykey - The Key to get the default value forKey or the fallback valuepublic <T> void set(Key<T> key, T value)
RegistryKeyprotected <T> void setDefault(Key<T> key, T value)
public <T> void remove(Key<T> key)
RegistryKeypublic <T> void transform(Key<T> key, java.util.function.BiFunction<? super Key<T>,? super T,? extends T> transformer)
RegistryKeypublic <T> void transform(Key<T> key, java.util.function.Function<? super T,? extends T> transformer)
RegistryKeypublic <T> void addToCollection(Key<? extends java.util.Collection<T>> key, T value)
RegistryCollection value for the provided KeyaddToCollection in interface RegistryT - The value type of the provided Keykey - The Key of the collection
to add the provided value tovalue - The value to addpublic <T> void removeFromCollection(Key<? extends java.util.Collection<T>> key, T value)
RegistryCollection value for the provided KeyremoveFromCollection in interface RegistryT - The value type of the provided Keykey - The Key of the collection
to add the provided value tovalue - The value to addpublic <K,T> void putInMap(Key<? extends java.util.Map<K,T>> key, K mapKey, T mapValue)
RegistryMap value for the provided KeyputInMap in interface RegistryK - The key type of the map value for the provided keyT - The value type of the map value for the provided keykey - The Key of the map to add the
provided key and value pair tomapKey - The map key to addmapValue - The map value to addpublic <K,T> void removeFromMap(Key<? extends java.util.Map<K,T>> key, K mapKey)
RegistryMap value for the provided KeyremoveFromMap in interface RegistryK - The key type of the map value for the provided keyT - The value type of the map value for the provided keykey - The Key of the map to remove the provided mapKey frommapKey - The map key to removepublic void load()
Registrylisteners that were
added before this call.load in interface RegistryEnvironment.reload(),
Registry.whenLoaded(Runnable)public void whenLoaded(java.lang.Runnable listener)
RegistryRunnable to be loaded on Registry.load()whenLoaded in interface Registrylistener - Listener to addRegistry.load()public java.lang.String toString()
toString in class java.lang.Object