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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Value
computeIfAbsent(Key key, ISerializableThrowingFunction<? super Key,? extends Value> loader)
Gets the value for the given key.Value
getIfPresent(Key key)
Gets the value associated with the given key.void
remove(Key key)
Removes the value at the given key, if present.Value
removeAndGetIfPresent(Key key)
Removes the value at the given key, if present, and returns the removed value.
-
-
-
Method Detail
-
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
Value getIfPresent(Key key)
Gets the value associated with the given key. Returns null if no value exists yet.- Parameters:
key
- The key to get the value for.- Returns:
- The associated value, if present, or null if no value exists.
-
remove
void remove(Key key)
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
Value removeAndGetIfPresent(Key key)
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.
-
-