ExtensionContext.Store@API(status=INTERNAL, since="5.0") public class NamespaceAwareStore extends java.lang.Object implements ExtensionContext.Store
ExtensionContext.Store.CloseableResource| Constructor | Description |
|---|---|
NamespaceAwareStore(ExtensionValuesStore valuesStore,
ExtensionContext.Namespace namespace) |
| Modifier and Type | Method | 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. |
getOrComputeIfAbsentpublic NamespaceAwareStore(ExtensionValuesStore valuesStore, ExtensionContext.Namespace namespace)
public java.lang.Object get(java.lang.Object key)
ExtensionContext.Storekey.
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.Storekey - the key; never nullnullExtensionContext.Store.get(Object, Class)public <T> T get(java.lang.Object key,
java.lang.Class<T> requiredType)
ExtensionContext.Storekey.
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.StoreT - the value typekey - the key; never nullrequiredType - the required type of the value; never nullnullExtensionContext.Store.get(Object)public <K,V> java.lang.Object getOrComputeIfAbsent(K key,
java.util.function.Function<K,V> defaultCreator)
ExtensionContext.Storekey.
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.
If the created value is an instance of ExtensionContext.Store.CloseableResource
the close() method will be invoked on the stored object when
the store is closed.
getOrComputeIfAbsent in interface ExtensionContext.StoreK - the key typeV - the value typekey - the key; never nulldefaultCreator - the function called with the supplied key
to create a new value; never nullnullExtensionContext.Store.getOrComputeIfAbsent(Class),
ExtensionContext.Store.getOrComputeIfAbsent(Object, Function, Class),
ExtensionContext.Store.CloseableResourcepublic <K,V> V getOrComputeIfAbsent(K key,
java.util.function.Function<K,V> defaultCreator,
java.lang.Class<V> requiredType)
ExtensionContext.Storekey.
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.
If requiredType implements ExtensionContext.Store.CloseableResource
the close() method will be invoked on the stored object when
the store is closed.
getOrComputeIfAbsent in interface ExtensionContext.StoreK - 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 nullnullExtensionContext.Store.getOrComputeIfAbsent(Class),
ExtensionContext.Store.getOrComputeIfAbsent(Object, Function),
ExtensionContext.Store.CloseableResourcepublic void put(java.lang.Object key,
java.lang.Object value)
ExtensionContext.Storevalue for later retrieval under the supplied key.
A stored value is visible in child ExtensionContexts for the store's Namespace unless they
overwrite it.
If the value is an instance of ExtensionContext.Store.CloseableResource
the close() method will be invoked on the stored object when
the store is closed.
put in interface ExtensionContext.Storekey - the key under which the value should be stored; never
nullvalue - the value to store; may be nullExtensionContext.Store.CloseableResourcepublic java.lang.Object remove(java.lang.Object key)
ExtensionContext.Storekey.
The value will only be removed in the current ExtensionContext,
not in ancestors. In addition, the ExtensionContext.Store.CloseableResource API will not
be honored for values that are manually removed via this method.
For greater type safety, consider using ExtensionContext.Store.remove(Object, Class)
instead.
remove in interface ExtensionContext.Storekey - the key; never nullnull 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.Storekey.
The value will only be removed in the current ExtensionContext,
not in ancestors. In addition, the ExtensionContext.Store.CloseableResource API will not
be honored for values that are manually removed via this method.
remove in interface ExtensionContext.StoreT - the value typekey - the key; never nullrequiredType - the required type of the value; never nullnull if no value was present
for the specified keyExtensionContext.Store.remove(Object)