Class NamespaceAwareStore
- java.lang.Object
-
- org.junit.jupiter.engine.execution.NamespaceAwareStore
-
- All Implemented Interfaces:
ExtensionContext.Store
@API(status=INTERNAL, since="5.0") public class NamespaceAwareStore extends java.lang.Object implements ExtensionContext.Store
- Since:
- 5.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.ExtensionContext.Store
ExtensionContext.Store.CloseableResource
-
-
Constructor Summary
Constructors Constructor Description NamespaceAwareStore(ExtensionValuesStore valuesStore, ExtensionContext.Namespace namespace)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get(java.lang.Object key)
Get the value that is stored under the suppliedkey
.<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 suppliedkey
.<K,V> java.lang.Object
getOrComputeIfAbsent(K key, java.util.function.Function<K,V> defaultCreator)
Get the value that is stored under the suppliedkey
.<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 suppliedkey
.void
put(java.lang.Object key, java.lang.Object value)
Store avalue
for later retrieval under the suppliedkey
.java.lang.Object
remove(java.lang.Object key)
Remove the value that was previously stored under the suppliedkey
.<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 suppliedkey
.-
Methods inherited from interface org.junit.jupiter.api.extension.ExtensionContext.Store
getOrComputeIfAbsent
-
-
-
-
Constructor Detail
-
NamespaceAwareStore
public NamespaceAwareStore(ExtensionValuesStore valuesStore, ExtensionContext.Namespace namespace)
-
-
Method Detail
-
get
public java.lang.Object get(java.lang.Object key)
Description copied from interface:ExtensionContext.Store
Get the value that is stored under the suppliedkey
.If no value is stored in the current
ExtensionContext
for the suppliedkey
, ancestors of the context will be queried for a value with the samekey
in theNamespace
used to create this store.For greater type safety, consider using
ExtensionContext.Store.get(Object, Class)
instead.- Specified by:
get
in interfaceExtensionContext.Store
- Parameters:
key
- the key; nevernull
- Returns:
- the value; potentially
null
- See Also:
ExtensionContext.Store.get(Object, Class)
-
get
public <T> T get(java.lang.Object key, java.lang.Class<T> requiredType)
Description copied from interface:ExtensionContext.Store
Get the value of the specified required type that is stored under the suppliedkey
.If no value is stored in the current
ExtensionContext
for the suppliedkey
, ancestors of the context will be queried for a value with the samekey
in theNamespace
used to create this store.- Specified by:
get
in interfaceExtensionContext.Store
- Type Parameters:
T
- the value type- Parameters:
key
- the key; nevernull
requiredType
- the required type of the value; nevernull
- Returns:
- the value; potentially
null
- See Also:
ExtensionContext.Store.get(Object)
-
getOrComputeIfAbsent
public <K,V> java.lang.Object getOrComputeIfAbsent(K key, java.util.function.Function<K,V> defaultCreator)
Description copied from interface:ExtensionContext.Store
Get the value that is stored under the suppliedkey
.If no value is stored in the current
ExtensionContext
for the suppliedkey
, ancestors of the context will be queried for a value with the samekey
in theNamespace
used to create this store. If no value is found for the suppliedkey
, a new value will be computed by thedefaultCreator
(given thekey
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
theclose()
method will be invoked on the stored object when the store is closed.- Specified by:
getOrComputeIfAbsent
in interfaceExtensionContext.Store
- Type Parameters:
K
- the key typeV
- the value type- Parameters:
key
- the key; nevernull
defaultCreator
- the function called with the suppliedkey
to create a new value; nevernull
- Returns:
- the value; potentially
null
- See Also:
ExtensionContext.Store.getOrComputeIfAbsent(Class)
,ExtensionContext.Store.getOrComputeIfAbsent(Object, Function, Class)
,ExtensionContext.Store.CloseableResource
-
getOrComputeIfAbsent
public <K,V> V getOrComputeIfAbsent(K key, java.util.function.Function<K,V> defaultCreator, java.lang.Class<V> requiredType)
Description copied from interface:ExtensionContext.Store
Get the value of the specified required type that is stored under the suppliedkey
.If no value is stored in the current
ExtensionContext
for the suppliedkey
, ancestors of the context will be queried for a value with the samekey
in theNamespace
used to create this store. If no value is found for the suppliedkey
, a new value will be computed by thedefaultCreator
(given thekey
as input), stored, and returned.If
requiredType
implementsExtensionContext.Store.CloseableResource
theclose()
method will be invoked on the stored object when the store is closed.- Specified by:
getOrComputeIfAbsent
in interfaceExtensionContext.Store
- Type Parameters:
K
- the key typeV
- the value type- Parameters:
key
- the key; nevernull
defaultCreator
- the function called with the suppliedkey
to create a new value; nevernull
requiredType
- the required type of the value; nevernull
- Returns:
- the value; potentially
null
- See Also:
ExtensionContext.Store.getOrComputeIfAbsent(Class)
,ExtensionContext.Store.getOrComputeIfAbsent(Object, Function)
,ExtensionContext.Store.CloseableResource
-
put
public void put(java.lang.Object key, java.lang.Object value)
Description copied from interface:ExtensionContext.Store
Store avalue
for later retrieval under the suppliedkey
.A stored
value
is visible in childExtensionContexts
for the store'sNamespace
unless they overwrite it.If the
value
is an instance ofExtensionContext.Store.CloseableResource
theclose()
method will be invoked on the stored object when the store is closed.- Specified by:
put
in interfaceExtensionContext.Store
- Parameters:
key
- the key under which the value should be stored; nevernull
value
- the value to store; may benull
- See Also:
ExtensionContext.Store.CloseableResource
-
remove
public java.lang.Object remove(java.lang.Object key)
Description copied from interface:ExtensionContext.Store
Remove the value that was previously stored under the suppliedkey
.The value will only be removed in the current
ExtensionContext
, not in ancestors. In addition, theExtensionContext.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.- Specified by:
remove
in interfaceExtensionContext.Store
- Parameters:
key
- the key; nevernull
- Returns:
- the previous value or
null
if no value was present for the specified key - See Also:
ExtensionContext.Store.remove(Object, Class)
-
remove
public <T> T remove(java.lang.Object key, java.lang.Class<T> requiredType)
Description copied from interface:ExtensionContext.Store
Remove the value of the specified required type that was previously stored under the suppliedkey
.The value will only be removed in the current
ExtensionContext
, not in ancestors. In addition, theExtensionContext.Store.CloseableResource
API will not be honored for values that are manually removed via this method.- Specified by:
remove
in interfaceExtensionContext.Store
- Type Parameters:
T
- the value type- Parameters:
key
- the key; nevernull
requiredType
- the required type of the value; nevernull
- Returns:
- the previous value or
null
if no value was present for the specified key - See Also:
ExtensionContext.Store.remove(Object)
-
-