Interface IResourceStoreManager
- All Superinterfaces:
AutoCloseable
AutoCloseable or file references that need to be released when the
lifecycle of the object holding this manager ends.
A store manager lets you access different typed stores for different types of keys and values. There are two store variants: a "normal" store and a versioned store. A normal store allows associating a single value with a key. A versioned store allows binds the liveness of a value to a version. For example, the key could be a file, the version the last modified date of the file, and the value some data computed from the file contents, such as a thumbnail or the dimensions of an image. The versioned store will automatically discard stale values and reloads them when the version changes.
Unless a method explicitly states otherwise, all values that implement AutoCloseable will be closed either
when they are removed from the store, or when the manager is closed, whichever comes first. In particular, the
removeAndGetIfPresent will let out access the removed value, and won't close them.
- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceManages values associated with a certain type of key.static interfaceManages values associated with a certain type of key.static interfaceSame asIResourceStoreManager.IResourceStore, but with a bound loader that does not need to be specified each time when requesting a value for a key.static interfaceManages values associated with a certain type of key.static interfaceManages values associated with a certain type of key.static interfaceSame asIResourceStoreManager.IVersionedResourceStore, but with a bound loader that does not need to be specified each time when requesting a value for a key.static interfaceSame asIResourceStoreManager.IVersionedResourceStore, but with a loader and bound version extractor that do not need to be specified each time when requesting a value for a key.static interfaceSame asIResourceStoreManager.IVersionedResourceStore, but with a bound loader that does not need to be specified each time when requesting a value for a key.static interfaceSame asIResourceStoreManager.IVersionedResourceStore, but with a bound version extractor that does not need to be specified each time when requesting a value for a key.static interfaceSame asIResourceStoreManager.IVersionedResourceStore, but with a bound version extractor that does not need to be specified each time when requesting a value for a key. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisOpen()Checks whether this store manager is still open.<Key,Value>
IResourceStoreManager.IResourceStore<Key, Value> Gets a store for the given key and value types, which can be used to associate a value with a particular key.default <Key,Value>
IResourceStoreManager.IResourceStore<Key, Value> Gets a store for the given key and value types, which can be used to associate a value with a particular key.<Key,Value>
IResourceStoreManager.IVersionedResourceStore<Key, Value> versionedStoreFor(Class<Key> keyType, Class<Value> valueType) Gets a versioned store for the given key and value types, which can be used to associate a value with a particular key and version.default <Key,Value>
IResourceStoreManager.IVersionedResourceStore<Key, Value> versionedStoreFor(Key key, Class<Value> valueType) Gets a versioned store for the given key and value types, which can be used to associate a value with a particular key and version.Methods inherited from interface AutoCloseable
close
-
Method Details
-
isOpen
boolean isOpen()Checks whether this store manager is still open. If it is not open, all methods will throw anIllegalStateException. SeeAutoCloseable.close().- Returns:
- True if the store manager is still open, false otherwise.
-
storeFor
default <Key,Value> IResourceStoreManager.IResourceStore<Key,Value> storeFor(Key key, Class<Value> valueType) Gets a store for the given key and value types, which can be used to associate a value with a particular key. Multiple calls to this method with the same type will return the same store.This method does the same as
storeFor(Class, Class), but with the key type inferred from the key instance. This helps to avoid unchecked warnings when the key type has type parameters.- Type Parameters:
Key- The type of the key.Value- The type of the value.- Parameters:
key- An instance of the key type.valueType- The type of the associated value.- Returns:
- The store for associating values with keys.
-
storeFor
<Key,Value> IResourceStoreManager.IResourceStore<Key,Value> storeFor(Class<Key> keyType, Class<Value> valueType) Gets a store for the given key and value types, which can be used to associate a value with a particular key. Multiple calls to this method with the same type will return the same store.- Type Parameters:
Key- The type of the key.Value- The type of the value.- Parameters:
keyType- The type of the key.valueType- The type of the associated value.- Returns:
- The store for associating values with keys.
-
versionedStoreFor
default <Key,Value> IResourceStoreManager.IVersionedResourceStore<Key,Value> versionedStoreFor(Key key, Class<Value> valueType) Gets a versioned store for the given key and value types, which can be used to associate a value with a particular key and version. When the version changes, the existing value will be considered stale and removed; and a new value will be loaded using the configured loader. Multiple calls to this method with the same type will return the same store.This method does the same as
versionedStoreFor(Class, Class), but with the key type inferred from the key instance. This helps to avoid unchecked warnings when the key type has type parameters.- Type Parameters:
Key- The type of the key.Value- The type of the value.- Parameters:
key- An instance of the key type.valueType- The type of the associated value.- Returns:
- The store for associating values with keys.
-
versionedStoreFor
<Key,Value> IResourceStoreManager.IVersionedResourceStore<Key,Value> versionedStoreFor(Class<Key> keyType, Class<Value> valueType) Gets a versioned store for the given key and value types, which can be used to associate a value with a particular key and version. When the version changes, the existing value will be considered stale and removed; and a new value will be loaded using the configured loader. Multiple calls to this method with the same type will return the same store.- Type Parameters:
Key- The type of the key.Value- The type of the value.- Parameters:
keyType- The type of the key.valueType- The type of the associated value.- Returns:
- The store for associating values with keys.
-