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 fromStoreService
s.- 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 StoreService
getStoreService()
Gets theStoreService
implementation to use.<K extends Comparable<K>,V extends Serializable>
Store<K,V>newGenericStore(Class<K> keyClass, Class<V> valueClass)
Generates a new generic store instance from the most appropriate service.<V extends Serializable>
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 theStoreService
implementation to use.- Returns:
- The best
StoreService
implementation.
-
newGenericStore
public <K extends Comparable<K>,V extends Serializable> 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 beComparable
in 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 extends Serializable> 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.
-
-