Class NamespaceAwareStore
- All Implemented Interfaces:
ExtensionContext.Store
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.ExtensionContext.Store
ExtensionContext.Store.CloseableResource -
Constructor Summary
ConstructorsConstructorDescriptionNamespaceAwareStore(NamespacedHierarchicalStore<Namespace> valuesStore, Namespace namespace) -
Method Summary
Modifier and TypeMethodDescription<K,V> Object computeIfAbsent(K key, Function<? super K, ? extends V> defaultCreator) Return the value of the specified required type that is stored under the suppliedkey.<K,V> V computeIfAbsent(K key, Function<? super K, ? extends V> defaultCreator, Class<V> requiredType) Get the value of the specified required type that is stored under the suppliedkey.@Nullable ObjectGet the value that is stored under the suppliedkey.<T> @Nullable TGet the value of the specified required type that is stored under the suppliedkey.getOrComputeIfAbsent(K key, Function<? super K, ? extends V> defaultCreator) Get the value that is stored under the suppliedkey.<K, V extends @Nullable Object>
@Nullable VgetOrComputeIfAbsent(K key, Function<? super K, ? extends V> defaultCreator, Class<V> requiredType) Get the value of the specified required type that is stored under the suppliedkey.voidStore avaluefor later retrieval under the suppliedkey.@Nullable ObjectRemove the value that was previously stored under the suppliedkey.<T> @Nullable TRemove the value of the specified required type that was previously stored under the suppliedkey.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.ExtensionContext.Store
computeIfAbsent, getOrComputeIfAbsent, getOrDefault
-
Constructor Details
-
NamespaceAwareStore
-
-
Method Details
-
get
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:
-
get
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:
-
getOrComputeIfAbsent
public <K, V extends @Nullable Object> @Nullable Object getOrComputeIfAbsent(K key, Function<? super K, ? extends 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.computeIfAbsent(Object, Function, Class)instead.If the created value is an instance of
ExtensionContext.Store.CloseableResourceorAutoCloseable(unless thejunit.jupiter.extensions.store.close.autocloseable.enabledconfiguration parameter is set tofalse), then theclose()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; nevernullbut may returnnull- Returns:
- the value; potentially
null - See Also:
-
getOrComputeIfAbsent
public <K, V extends @Nullable Object> @Nullable V getOrComputeIfAbsent(K key, Function<? super K, ? extends 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 the created value implements
ExtensionContext.Store.CloseableResourceorAutoCloseable(unless thejunit.jupiter.extensions.store.close.autocloseable.enabledconfiguration parameter is set tofalse), then theclose()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; nevernullbut may returnnullrequiredType- the required type of the value; nevernull- Returns:
- the value; potentially
null - See Also:
-
computeIfAbsent
Description copied from interface:ExtensionContext.StoreReturn 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 suppliedkeyor the value isnull, a new value will be computed by thedefaultCreator(given thekeyas input), stored, and returned.For greater type safety, consider using
ExtensionContext.Store.computeIfAbsent(Object, Function, Class)instead.If the created value is an instance of
ExtensionContext.Store.CloseableResourceorAutoCloseable(unless thejunit.jupiter.extensions.store.close.autocloseable.enabledconfiguration parameter is set tofalse), then theclose()method will be invoked on the stored object when the store is closed.- Specified by:
computeIfAbsentin 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; nevernulland must not returnnull- Returns:
- the value; never
null - See Also:
-
computeIfAbsent
public <K,V> V computeIfAbsent(K key, Function<? super K, ? extends 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 suppliedkeyor the value isnull, a new value will be computed by thedefaultCreator(given thekeyas input), stored, and returned.If the created value is an instance of
ExtensionContext.Store.CloseableResourceorAutoCloseable(unless thejunit.jupiter.extensions.store.close.autocloseable.enabledconfiguration parameter is set tofalse), then theclose()method will be invoked on the stored object when the store is closed.- Specified by:
computeIfAbsentin 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; nevernulland must not returnnullrequiredType- the required type of the value; nevernull- Returns:
- the value; never
null - See Also:
-
put
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.CloseableResourceorAutoCloseable(unless thejunit.jupiter.extensions.store.close.autocloseable.enabledconfiguration parameter is set tofalse), then theclose()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:
-
remove
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.CloseableResourceandAutoCloseableAPI 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:
-
remove
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.CloseableResourceandAutoCloseableAPI 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:
-