T - The specific type used by this Criteria as arguments.R - The specific type returned by this Criteria when applied to a storage.
Encapsulates the idea of criteria that can apply themselves to a StorageManager query. This can be
anything like the WHERE clause of a SQL query for relational storages or something that modifies the storage or
whatever else. It provides the get(StorageManager) method to retrieve the data from the storage as a
key-value mapping to the raw data stored. The Criteria can also wrap its results in its own format when
using the retrieve(StorageManager) interface to return objects of an expected type.
A specific Criteria is intended to be implemented along with the particular StorageManager so that
non-public interfaces can be shared between them.
In order to allow arbitrary changes or queries to the storage, the apply(StorageManager, Object) method is
also provided. This method is intended to be used for anything dealing with the storage, including retrieval. The
specific arguments for the query are left to the specific criteria.
public interface Criteria<T,R>
| Modifier and Type | Method and Description |
|---|---|
<V extends Serializable> |
apply(StorageManager<V> storage,
T query)
Applies the criteria to the
StorageManager. |
static <V extends Serializable,S extends StorageManager> |
checkType(StorageManager<V> storage,
Class<S> klazz)
Utility method to help check and cast if a given storage is of the given type.
|
<V extends Serializable> |
get(StorageManager<V> storage)
Retrieves data from the given
StorageManager as a CompletableFuture resolving to a key-value
mapping of the raw data stored in the storage. |
<V extends Serializable> |
retrieve(StorageManager<V> storage)
Retrieves data from the given
StorageManager as a CompletableFuture resolving to the specific
return type of this Criteria. |
<V extends Serializable> CompletableFuture<Map<String,V>> get(StorageManager<V> storage)
StorageManager as a CompletableFuture resolving to a key-value
mapping of the raw data stored in the storage.V - The type of the data stored in the storage.storage - The StorageManager to retrieve data from.CompletableFuture that resolves to a Map of String keys to the raw data in the storage.<V extends Serializable> CompletableFuture<R> retrieve(StorageManager<V> storage)
StorageManager as a CompletableFuture resolving to the specific
return type of this Criteria.V - The type of the data stored in the storage.storage - The StorageManager to retrieve data from.CompletableFuture that resolves to the return type of this Criteria.<V extends Serializable> CompletableFuture<R> apply(StorageManager<V> storage, T query)
StorageManager. This is left to the specific criteria to choose what to do.V - The type of the data stored in the storage.storage - The StorageManager to apply this to.query - The specific query to apply to this Criteria.CompletableFuture that resolves to the return type of this Criteria.static <V extends Serializable,S extends StorageManager> S checkType(StorageManager<V> storage, Class<S> klazz)
V - The type of the storage.S - The super-type of the storage.storage - The storage to check.klazz - The non-null super-type that the given storage is supposed to inherit from.UnsupportedOperationException - if the storage is not an instance of the given class.Copyright © 2021. All rights reserved.