Interface IResourceStoreManager.IResourceStoreBase<Key,Value>
- Type Parameters:
Key- The type of the key.Value- The type of the associated value.
- All Known Subinterfaces:
IResourceStoreManager.IResourceStore<Key,Value>, IResourceStoreManager.IResourceStoreWithLoader<Key, Value>
- Enclosing interface:
IResourceStoreManager
public static interface IResourceStoreManager.IResourceStoreBase<Key,Value>
Manages values associated with a certain type of key. Each key can be associated with a value, such as e.g. a
file with a thumbnail.
- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
-
Method Summary
Modifier and TypeMethodDescriptioncomputeIfAbsent(Key key, ISerializableThrowingFunction<? super Key, ? extends Value> loader) Gets the value for the given key.getIfPresent(Key key) Gets the value associated with the given key.voidRemoves the value at the given key, if present.removeAndGetIfPresent(Key key) Removes the value at the given key, if present, and returns the removed value.
-
Method Details
-
computeIfAbsent
Value computeIfAbsent(Key key, ISerializableThrowingFunction<? super Key, ? extends Value> loader) throws IOException Gets the value for the given key. When the value exists already, it will be returned. If the value does not exist yet, it will be loaded using the given loader.- Parameters:
key- The key for which to get the value.loader- The loader to use if the value does not exist or is stale.- Returns:
- The associated value, either from the store if still fresh, or obtained from the bound loader.
- Throws:
IOException- If the loader throws an exception.
-
getIfPresent
-
remove
Removes the value at the given key, if present. Does nothing if no value exists yet.- Parameters:
key- The key to remove the value for.
-
removeAndGetIfPresent
Removes the value at the given key, if present, and returns the removed value. Does nothing if no value exists yet. The value returned by this method will NOT be closed if it implementsAutoCloseable.- Parameters:
key- The key to remove the value for.- Returns:
- The removed value, if present, or null if no value exists.
-