public static interface ExtensionContext.Store
Store provides methods for extensions to save and retrieve data.| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
get(java.lang.Object key)
Get the value that is stored under the supplied
key. |
<V> V |
get(java.lang.Object key,
java.lang.Class<V> requiredType)
Get the value of the specified required type that is stored under
the supplied
key. |
<K,V> java.lang.Object |
getOrComputeIfAbsent(K key,
java.util.function.Function<K,V> defaultCreator)
Get the value that is stored under the supplied
key. |
<K,V> V |
getOrComputeIfAbsent(K key,
java.util.function.Function<K,V> defaultCreator,
java.lang.Class<V> requiredType)
Get the value of the specified required type that is stored under the
supplied
key. |
void |
put(java.lang.Object key,
java.lang.Object value)
Store a
value for later retrieval under the supplied key. |
java.lang.Object |
remove(java.lang.Object key)
Remove the value that was previously stored under the supplied
key. |
<V> V |
remove(java.lang.Object key,
java.lang.Class<V> requiredType)
Remove the value of the specified required type that was previously stored
under the supplied
key. |
java.lang.Object get(java.lang.Object key)
key.
If no value is stored in the current ExtensionContext
for the supplied key, ancestors of the context will be queried
for a value with the same key in the Namespace used
to create this store.
For greater type safety, consider using get(Object, Class)
instead.
key - the key; never nullnullget(Object, Class)<V> V get(java.lang.Object key,
java.lang.Class<V> requiredType)
key.
If no value is stored in the current ExtensionContext
for the supplied key, ancestors of the context will be queried
for a value with the same key in the Namespace used
to create this store.
V - the value typekey - the key; never nullrequiredType - the required type of the value; never nullnullget(Object)<K,V> java.lang.Object getOrComputeIfAbsent(K key,
java.util.function.Function<K,V> defaultCreator)
key.
If no value is stored in the current ExtensionContext
for the supplied key, ancestors of the context will be queried
for a value with the same key in the Namespace used
to create this store. If no value is found for the supplied key,
a new value will be computed by the defaultCreator (given
the key as input), stored, and returned.
For greater type safety, consider using
getOrComputeIfAbsent(Object, Function, Class) instead.
K - the key typeV - the value typekey - the key; never nulldefaultCreator - the function called with the supplied key
to create a new value; never nullnullgetOrComputeIfAbsent(Object, Function, Class)<K,V> V getOrComputeIfAbsent(K key,
java.util.function.Function<K,V> defaultCreator,
java.lang.Class<V> requiredType)
key.
If no value is stored in the current ExtensionContext
for the supplied key, ancestors of the context will be queried
for a value with the same key in the Namespace used
to create this store. If no value is found for the supplied key,
a new value will be computed by the defaultCreator (given
the key as input), stored, and returned.
K - the key typeV - the value typekey - the key; never nulldefaultCreator - the function called with the supplied key
to create a new value; never nullrequiredType - the required type of the value; never nullnullgetOrComputeIfAbsent(Object, Function)void put(java.lang.Object key,
java.lang.Object value)
value for later retrieval under the supplied key.
A stored value is visible in child ExtensionContexts for the store's Namespace unless they
overwrite it.
key - the key under which the value should be stored; never
nullvalue - the value to store; may be nulljava.lang.Object remove(java.lang.Object key)
key.
The value will only be removed in the current ExtensionContext,
not in ancestors.
For greater type safety, consider using remove(Object, Class)
instead.
key - the key; never nullnull if no value was present
for the specified keyremove(Object, Class)<V> V remove(java.lang.Object key,
java.lang.Class<V> requiredType)
key.
The value will only be removed in the current ExtensionContext,
not in ancestors.
V - the value typekey - the key; never nullrequiredType - the required type of the value; never nullnull if no value was present
for the specified keyremove(Object)