Class NamespaceAwareStore
- All Implemented Interfaces:
ExtensionContext.Store, Store
-
Nested Class Summary
Nested classes/interfaces inherited from interface 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.static NamespaceAwareStorecreateAdapter(NamespacedHierarchicalStore<Namespace> valuesStore, Namespace namespace) Get 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.getOrComputeIfAbsent(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.Remove 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ExtensionContext.Store
getOrComputeIfAbsentMethods inherited from interface Store
computeIfAbsent, getOrDefault
-
Constructor Details
-
NamespaceAwareStore
-
-
Method Details
-
createAdapter
public static NamespaceAwareStore createAdapter(NamespacedHierarchicalStore<Namespace> valuesStore, Namespace namespace) -
get
Description copied from interface:StoreGet the value that is stored under the suppliedkey.If no value is stored in this store for the supplied
key, parent stores (if any) will be queried for a value with the samekeyin theNamespaceused to create this store.For greater type safety, consider using
Store.get(Object, Class)instead. -
get
Description copied from interface:StoreGet the value of the specified required type that is stored under the suppliedkey.If no value is stored in this store for the supplied
key, parent stores (if any) will be queried for a value with the samekeyin theNamespaceused to create this store. -
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
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:StoreReturn the value of the specified required type that is stored under the suppliedkey.If no value is stored in this store for the supplied
key, parent stores (if any) 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
Store.computeIfAbsent(Object, Function, Class)instead.If the created value is an instance of
AutoCloseable, then theclose()method will be invoked on the stored object when the store is closed, unless documented otherwise by a subinterface.- Specified by:
computeIfAbsentin interfaceStore- 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:StoreGet the value of the specified required type that is stored under the suppliedkey.If no value is stored in this store for the supplied
key, parent stores (if any) 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
AutoCloseable, then theclose()method will be invoked on the stored object when the store is closed, unless documented otherwise by a subinterface.- Specified by:
computeIfAbsentin interfaceStore- 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:StoreStore avaluefor later retrieval under the suppliedkey.A stored
valueis visible in child stores for the store'sNamespaceunless they overwrite it.If the
valueis an instance ofAutoCloseable, then theclose()method will be invoked on the stored object when the store is closed, unless documented otherwise by a subinterface. -
remove
Description copied from interface:StoreRemove the value that was previously stored under the suppliedkey.The value will only be removed in this store, not in parent stores. In addition, the
AutoCloseableAPI will not be honored for values that are manually removed via this method.For greater type safety, consider using
Store.remove(Object, Class)instead. -
remove
Description copied from interface:StoreRemove the value of the specified required type that was previously stored under the suppliedkey.The value will only be removed in this store, not in parent stores. In addition, the
AutoCloseableAPI will not be honored for values that are manually removed via this method.
-