@API(value=Internal) public class NamespaceAwareStore extends Object implements ExtensionContext.Store
Constructor and Description |
---|
NamespaceAwareStore(ExtensionValuesStore valuesStore,
ExtensionContext.Namespace namespace) |
Modifier and Type | Method and Description |
---|---|
Object |
get(Object key)
Get the value that is stored under the supplied
key . |
<T> T |
get(Object key,
Class<T> 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 . |
<T> T |
remove(Object key,
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 Object get(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(Object key, 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> Object getOrComputeIfAbsent(K key, 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, Function<K,V> defaultCreator, 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(Object key, 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 Object remove(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(Object key, 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)