public interface Registry
| 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. |
default <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. |
default <T> T |
getOrDefault(Key<T> key)
Gets this registry's value for the provided
Key
or the default 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 |
<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 load() |
<T> T getUnsafe(Key<T> key)
Key
and throws an exception if it is not present.<T> java.util.Optional<T> get(Key<T> key)
Key
or Optional.empty() if it is not present.default <T> T getDefault(Key<T> key)
Key
or the fallback value if it is not present.default <T> T getOrDefault(Key<T> key)
Key
or the default value if it is not present.<T> void transform(Key<T> key, java.util.function.BiFunction<? super Key<T>,? super T,? extends T> transformer)
Key<T> void transform(Key<T> key, java.util.function.Function<? super T,? extends T> transformer)
Key<T> void addToCollection(Key<? extends java.util.Collection<T>> key, T value)
Collection value for the provided Key<T> void removeFromCollection(Key<? extends java.util.Collection<T>> key, T value)
Collection value for the provided Key<K,T> void putInMap(Key<? extends java.util.Map<K,T>> key, K mapKey, T mapValue)
Map value for the provided KeyK - 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 add<K,T> void removeFromMap(Key<? extends java.util.Map<K,T>> key, K mapKey)
Map value for the provided KeyK - 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 removevoid load()
listeners that were
added before this call.Environment.reload(),
whenLoaded(Runnable)