public final class SimpleSnapshotEventGenerator extends Object implements SnapshotEventGenerator
SnapshotEventGenerator. It is
meant to be used in a functional style.SnapshotEventGenerator| Constructor and Description |
|---|
SimpleSnapshotEventGenerator(String supportedEventType,
java.util.function.BiFunction<Object,String,List<Snapshot>> snapshotEventFactory)
Creates a SnapshotEventGenerator for an event type, with filtering
support.
|
SimpleSnapshotEventGenerator(String supportedEventType,
java.util.function.Function<Object,List<Snapshot>> snapshotEventFactory)
Creates a SnapshotEventGenerator for an event type, which doesn't support
filtering.
|
| Modifier and Type | Method and Description |
|---|---|
List<Snapshot> |
generateSnapshots(Object withIdGreaterThan,
String filter)
Returns a batch of snapshots of given type (event type is an event
channel topic name).
|
String |
getSupportedEventType()
The name of the event type supported by this snapshot generator.
|
public SimpleSnapshotEventGenerator(String supportedEventType, java.util.function.Function<Object,List<Snapshot>> snapshotEventFactory)
supportedEventType - the eventType that this SnapShotEventProvider will support.snapshotEventFactory - a snapshot event factory function conforming to the
specification of
SnapshotEventGenerator.generateSnapshots(Object, String)
(but without the filter parameter). Any filter provided by the
caller will be thrown away.public SimpleSnapshotEventGenerator(String supportedEventType, java.util.function.BiFunction<Object,String,List<Snapshot>> snapshotEventFactory)
supportedEventType - the eventType that this SnapShotEventProvider will support.snapshotEventFactory - a snapshot event factory function conforming to the
specification of
SnapshotEventGenerator.generateSnapshots(Object, String).public List<Snapshot> generateSnapshots(Object withIdGreaterThan, String filter)
SnapshotEventGeneratorReturns a batch of snapshots of given type (event type is an event channel topic name). The implementation may return an arbitrary amount of results, but it must return at least one element if there are entities matching the parameters.
Calling this method must have no side effects.
The library will call your implementation like this:It is your responsibility to make sure that the returned events are ordered by their ID ascending and that, given you return a list of events for entities with IDs {id1, ..., idN}, there exists no entity with an ID between id1 and idN, that is not part of the result.
generateSnapshots in interface SnapshotEventGeneratorwithIdGreaterThan - if not null, only events for entities with an ID greater than
the given one must be returnedfilter - a filter for the snapshot generation mechanism. This value is
simply passed through from the request body of the REST
endpoint (or from any other triggering mechanism). If there
was no request body, this will be null.
Implementors can interpret it in whatever way they want (even
ignore it). All calls for one snapshot generation will receive
the same string.public String getSupportedEventType()
SnapshotEventGeneratorgetSupportedEventType in interface SnapshotEventGeneratorCopyright © 2018. All rights reserved.