public static interface ExtensionContext.Store
Store
provides methods for extensions to save and retrieve data.Modifier and Type | Method and Description |
---|---|
Object |
get(Object key)
Get the value that is stored under the supplied
key . |
<V> V |
get(Object key,
Class<V> requiredType)
Get the value of the specified required type that is stored under
the supplied
key . |
<K,V> Object |
getOrComputeIfAbsent(K key,
Function<K,V> defaultCreator)
Get the value that is stored under the supplied
key . |
<K,V> V |
getOrComputeIfAbsent(K key,
Function<K,V> defaultCreator,
Class<V> requiredType)
Get the value of the specified required type that is stored under the
supplied
key . |
void |
put(Object key,
Object value)
Store a
value for later retrieval under the supplied key . |
Object |
remove(Object key)
Remove the value that was previously stored under the supplied
key . |
<V> V |
remove(Object key,
Class<V> requiredType)
Remove the value of the specified required type that was previously stored
under the supplied
key . |
Object get(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 null
null
get(Object, Class)
<V> V get(Object key, 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 null
requiredType
- the required type of the value; never null
null
get(Object)
<K,V> Object getOrComputeIfAbsent(K key, 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 null
defaultCreator
- the function called with the supplied key
to create a new value; never null
null
getOrComputeIfAbsent(Object, Function, Class)
<K,V> V getOrComputeIfAbsent(K key, Function<K,V> defaultCreator, 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 null
defaultCreator
- the function called with the supplied key
to create a new value; never null
requiredType
- the required type of the value; never null
null
getOrComputeIfAbsent(Object, Function)
void put(Object key, 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
null
value
- the value to store; may be null
Object remove(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 null
null
if no value was present
for the specified keyremove(Object, Class)
<V> V remove(Object key, Class<V> requiredType)
key
.
The value will only be removed in the current ExtensionContext
,
not in ancestors.
V
- the value typekey
- the key; never null
requiredType
- the required type of the value; never null
null
if no value was present
for the specified keyremove(Object)