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 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 Objectget(Object key)Get the value that is stored under the suppliedkey.<T> Tget(Object key, Class<T> requiredType)Get the value of the specified required type that is stored under the suppliedkey.<K,V> ObjectgetOrComputeIfAbsent(K key, Function<K,V> defaultCreator)Get the value that is stored under the suppliedkey.<K,V> VgetOrComputeIfAbsent(K key, Function<K,V> defaultCreator, Class<V> requiredType)Get the value of the specified required type that is stored under the suppliedkey.voidput(Object key, Object value)Store avaluefor later retrieval under the suppliedkey.Objectremove(Object key)Remove the value that was previously stored under the suppliedkey.<T> Tremove(Object key, 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 Object get(Object key)
Description copied from interface:ExtensionContext.StoreGet the value that is stored under the suppliedkey.If no value is stored in the current
ExtensionContextfor the suppliedkey, ancestors of the context will be queried for a value with the samekeyin theNamespaceused to create this store.For greater type safety, consider using
ExtensionContext.Store.get(Object, Class)instead.- Specified by:
getin interfaceExtensionContext.Store- Parameters:
key- the key; nevernull- Returns:
- the value; potentially
null - See Also:
ExtensionContext.Store.get(Object, Class)
-
get
public <T> T get(Object key, Class<T> requiredType)
Description copied from interface:ExtensionContext.StoreGet the value of the specified required type that is stored under the suppliedkey.If no value is stored in the current
ExtensionContextfor the suppliedkey, ancestors of the context will be queried for a value with the samekeyin theNamespaceused to create this store.- Specified by:
getin interfaceExtensionContext.Store- Type Parameters:
T- the value type- Parameters:
key- the key; nevernullrequiredType- the required type of the value; nevernull- Returns:
- the value; potentially
null - See Also:
ExtensionContext.Store.get(Object)
-
getOrComputeIfAbsent
public <K,V> Object getOrComputeIfAbsent(K key, Function<K,V> defaultCreator)
Description copied from interface:ExtensionContext.StoreGet the value that is stored under the suppliedkey.If no value is stored in the current
ExtensionContextfor the suppliedkey, ancestors of the context will be queried for a value with the samekeyin theNamespaceused to create this store. If no value is found for the suppliedkey, a new value will be computed by thedefaultCreator(given thekeyas 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.CloseableResourcetheclose()method will be invoked on the stored object when the store is closed.- Specified by:
getOrComputeIfAbsentin interfaceExtensionContext.Store- Type Parameters:
K- the key typeV- the value type- Parameters:
key- the key; nevernulldefaultCreator- the function called with the suppliedkeyto 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, Function<K,V> defaultCreator, Class<V> requiredType)Description copied from interface:ExtensionContext.StoreGet the value of the specified required type that is stored under the suppliedkey.If no value is stored in the current
ExtensionContextfor the suppliedkey, ancestors of the context will be queried for a value with the samekeyin theNamespaceused to create this store. If no value is found for the suppliedkey, a new value will be computed by thedefaultCreator(given thekeyas input), stored, and returned.If
requiredTypeimplementsExtensionContext.Store.CloseableResourcetheclose()method will be invoked on the stored object when the store is closed.- Specified by:
getOrComputeIfAbsentin interfaceExtensionContext.Store- Type Parameters:
K- the key typeV- the value type- Parameters:
key- the key; nevernulldefaultCreator- the function called with the suppliedkeyto create a new value; nevernullrequiredType- 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(Object key, Object value)
Description copied from interface:ExtensionContext.StoreStore avaluefor later retrieval under the suppliedkey.A stored
valueis visible in childExtensionContextsfor the store'sNamespaceunless they overwrite it.If the
valueis an instance ofExtensionContext.Store.CloseableResourcetheclose()method will be invoked on the stored object when the store is closed.- Specified by:
putin interfaceExtensionContext.Store- Parameters:
key- the key under which the value should be stored; nevernullvalue- the value to store; may benull- See Also:
ExtensionContext.Store.CloseableResource
-
remove
public Object remove(Object key)
Description copied from interface:ExtensionContext.StoreRemove 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.CloseableResourceAPI 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:
removein interfaceExtensionContext.Store- Parameters:
key- the key; nevernull- Returns:
- the previous value or
nullif no value was present for the specified key - See Also:
ExtensionContext.Store.remove(Object, Class)
-
remove
public <T> T remove(Object key, Class<T> requiredType)
Description copied from interface:ExtensionContext.StoreRemove 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.CloseableResourceAPI will not be honored for values that are manually removed via this method.- Specified by:
removein interfaceExtensionContext.Store- Type Parameters:
T- the value type- Parameters:
key- the key; nevernullrequiredType- the required type of the value; nevernull- Returns:
- the previous value or
nullif no value was present for the specified key - See Also:
ExtensionContext.Store.remove(Object)
-
-