@API(value=Internal) public class NamespaceAwareStore extends java.lang.Object implements ExtensionContext.Store
Constructor and Description |
---|
NamespaceAwareStore(ExtensionValuesStore valuesStore,
ExtensionContext.Namespace namespace) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(java.lang.Object key)
Get the value that is stored under the supplied
key . |
<T> T |
get(java.lang.Object key,
java.lang.Class<T> 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 . |
<T> T |
remove(java.lang.Object key,
java.lang.Class<T> requiredType)
Remove the value of the specified required type that was previously stored
under the supplied
key . |
public NamespaceAwareStore(ExtensionValuesStore valuesStore, ExtensionContext.Namespace namespace)
public java.lang.Object get(java.lang.Object key)
ExtensionContext.Store
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 ExtensionContext.Store.get(Object, Class)
instead.
get
in interface ExtensionContext.Store
key
- the key; never null
null
ExtensionContext.Store.get(Object, Class)
public <T> T get(java.lang.Object key, java.lang.Class<T> requiredType)
ExtensionContext.Store
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.
get
in interface ExtensionContext.Store
T
- the value typekey
- the key; never null
requiredType
- the required type of the value; never null
null
ExtensionContext.Store.get(Object)
public <K,V> java.lang.Object getOrComputeIfAbsent(K key, java.util.function.Function<K,V> defaultCreator)
ExtensionContext.Store
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
ExtensionContext.Store.getOrComputeIfAbsent(Object, Function, Class)
instead.
getOrComputeIfAbsent
in interface ExtensionContext.Store
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
ExtensionContext.Store.getOrComputeIfAbsent(Object, Function, Class)
public <K,V> V getOrComputeIfAbsent(K key, java.util.function.Function<K,V> defaultCreator, java.lang.Class<V> requiredType)
ExtensionContext.Store
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.
getOrComputeIfAbsent
in interface ExtensionContext.Store
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
ExtensionContext.Store.getOrComputeIfAbsent(Object, Function)
public void put(java.lang.Object key, java.lang.Object value)
ExtensionContext.Store
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.
put
in interface ExtensionContext.Store
key
- the key under which the value should be stored; never
null
value
- the value to store; may be null
public java.lang.Object remove(java.lang.Object key)
ExtensionContext.Store
key
.
The value will only be removed in the current ExtensionContext
,
not in ancestors.
For greater type safety, consider using ExtensionContext.Store.remove(Object, Class)
instead.
remove
in interface ExtensionContext.Store
key
- the key; never null
null
if no value was present
for the specified keyExtensionContext.Store.remove(Object, Class)
public <T> T remove(java.lang.Object key, java.lang.Class<T> requiredType)
ExtensionContext.Store
key
.
The value will only be removed in the current ExtensionContext
,
not in ancestors.
remove
in interface ExtensionContext.Store
T
- 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 keyExtensionContext.Store.remove(Object)