Interface DataService
-
- All Known Implementing Classes:
DataSvc
public interface DataService
Service for sourcing, mapping and consuming data.The service is in charge of two data flows: - push, given to consumers - pull, obtained from sources
The mappers facilitate a one way type transformation if needed.
The interface is very abstract about how data is obtained, but here are my general ideas of where the abstraction is coming from. - push cause one or multiple consumers to modify stored data - pull cause one or multiple suppliers to fetch stored data - mappers are stateless type transformers in memory
Example use-case: - PlayerJoinEvent is mapped to a generic event - that generic event is then consumed and mapped until the data is in a database.
- Some kind of data is wanted to place on a web page - It is requested and the suppliers and mappers give the wanted type of data.
Further research needed: - Can this limited type system represent types of data that need parameters (such as differentiate between two servers data)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DataService.Mapping
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <A,B>
BmapTo(java.lang.Class<B> toType, A from)
<S> java.util.Optional<S>
pull(java.lang.Class<S> type)
default <S,P>
java.util.Optional<S>pull(java.lang.Class<S> type, java.lang.Class<P> parameterType)
default <S,P>
java.util.Optional<S>pull(java.lang.Class<S> type, java.util.function.Supplier<P> parameter)
<S,P>
java.util.Optional<S>pull(java.lang.Class<S> type, P parameter)
<M> DataService
push(java.lang.Class<M> type, M data)
<M> DataService
registerConsumer(java.lang.Class<M> type, java.util.function.Consumer<M> consumer)
<P,S>
DataServiceregisterDBSupplier(java.lang.Class<S> type, java.lang.Class<P> parameterType, java.util.function.Function<P,Query<S>> supplierWithParameter)
<A,B>
DataServiceregisterMapper(java.lang.Class<A> typeA, java.lang.Class<B> typeB, java.util.function.Function<A,B> mapper)
<P,S>
DataServiceregisterSupplier(java.lang.Class<S> type, java.lang.Class<P> parameterType, java.util.function.Function<P,S> supplierWithParameter)
<S> DataService
registerSupplier(java.lang.Class<S> type, java.util.function.Supplier<S> supplier)
-
-
-
Method Detail
-
push
<M> DataService push(java.lang.Class<M> type, M data)
-
pull
<S> java.util.Optional<S> pull(java.lang.Class<S> type)
-
pull
<S,P> java.util.Optional<S> pull(java.lang.Class<S> type, P parameter)
-
mapTo
<A,B> B mapTo(java.lang.Class<B> toType, A from)
-
pull
default <S,P> java.util.Optional<S> pull(java.lang.Class<S> type, java.lang.Class<P> parameterType)
-
pull
default <S,P> java.util.Optional<S> pull(java.lang.Class<S> type, java.util.function.Supplier<P> parameter)
-
registerMapper
<A,B> DataService registerMapper(java.lang.Class<A> typeA, java.lang.Class<B> typeB, java.util.function.Function<A,B> mapper)
-
registerConsumer
<M> DataService registerConsumer(java.lang.Class<M> type, java.util.function.Consumer<M> consumer)
-
registerSupplier
<S> DataService registerSupplier(java.lang.Class<S> type, java.util.function.Supplier<S> supplier)
-
registerSupplier
<P,S> DataService registerSupplier(java.lang.Class<S> type, java.lang.Class<P> parameterType, java.util.function.Function<P,S> supplierWithParameter)
-
registerDBSupplier
<P,S> DataService registerDBSupplier(java.lang.Class<S> type, java.lang.Class<P> parameterType, java.util.function.Function<P,Query<S>> supplierWithParameter)
-
-