Package discord4j.store.api.service
Class StoreServiceLoader
- java.lang.Object
-
- discord4j.store.api.service.StoreServiceLoader
-
public class StoreServiceLoader extends Object
A factory-esque object which provides save objects fromStoreServices.- See Also:
StoreService
-
-
Constructor Summary
Constructors Constructor Description StoreServiceLoader()Creates a reusable instance of the provider, service discovery occurs at this point!StoreServiceLoader(Map<Class<? extends StoreService>,Integer> priorityOverrides)Creates a reusable instance of the provider, service discovery occurs at this point!
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StoreServicegetStoreService()Gets theStoreServiceimplementation to use.<K extends Comparable<K>,V>
Store<K,V>newGenericStore(Class<K> keyClass, Class<V> valueClass)Generates a new generic store instance from the most appropriate service.<V> LongObjStore<V>newLongObjStore(Class<V> valueClass)Generates a new long-object store instance from the most appropriate service.
-
-
-
Constructor Detail
-
StoreServiceLoader
public StoreServiceLoader()
Creates a reusable instance of the provider, service discovery occurs at this point!
-
StoreServiceLoader
public StoreServiceLoader(Map<Class<? extends StoreService>,Integer> priorityOverrides)
Creates a reusable instance of the provider, service discovery occurs at this point!- Parameters:
priorityOverrides- Allows for manual overriding ofStoreService.order().
-
-
Method Detail
-
getStoreService
public StoreService getStoreService()
Gets theStoreServiceimplementation to use.- Returns:
- The best
StoreServiceimplementation.
-
newGenericStore
public <K extends Comparable<K>,V> Store<K,V> newGenericStore(Class<K> keyClass, Class<V> valueClass)
Generates a new generic store instance from the most appropriate service.- Type Parameters:
K- The key type which provides a 1:1 mapping to the value type. This type is also expected to beComparablein order to allow for range operations.V- The value type.- Parameters:
keyClass- The class of the keys.valueClass- The class of the values.- Returns:
- A mono which provides a store instance.
-
newLongObjStore
public <V> LongObjStore<V> newLongObjStore(Class<V> valueClass)
Generates a new long-object store instance from the most appropriate service.- Type Parameters:
V- The value type.- Parameters:
valueClass- The class of the values.- Returns:
- A mono which provides a store instance.
-
-