Interface SnapshotFilter
- All Superinterfaces:
Predicate<DomainEventData<?>>
- All Known Implementing Classes:
RevisionSnapshotFilter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface defining an
allow(DomainEventData) method to take snapshot data into account when
loading an aggregate. When providing an instance of this, take the following into account:
- Only return
falseif the snapshot data belongs to the corresponding aggregate and it does no conform to the desired format. - Return
trueif the snapshot data belongs to the corresponding aggregate and conforms to the desired format. - Return
trueif the snapshot data does not correspond to the desired aggregate.
Whether the DomainEventData corresponds to the right aggregate and is of the desired format, is dependent on
the Snapshotter instance being used. By default, the AggregateSnapshotter instances would be used.
In such a default set up, DomainEventData corresponding to the right aggregate means that the DomainEventData.getType() matches the aggregate's type. If DomainEventData is of the desired format
should be based on the EventData.getPayload(), which contains the entire aggregate state.
- Since:
- 4.4
- Author:
- Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanallow(DomainEventData<?> snapshotData) Function applied to filter out snapshot data in the form of aDomainEventData.static SnapshotFilterallowAll()ASnapshotFilterimplementation which allows all snapshots.default SnapshotFiltercombine(SnapshotFilter other) CombinesthisSnapshotFilterwith the giveotherfilter in an "AND" operation, effectively validating whether both returntrueon aallow(DomainEventData)call of each.static SnapshotFilterASnapshotFilterimplementation which rejects all snapshots.
-
Method Details
-
allow
Function applied to filter out snapshot data in the form of aDomainEventData. Returntrueif the data should be kept andfalseif it should be dropped.- Parameters:
snapshotData- the snapshot data to verify for filtering- Returns:
trueif the data should be kept andfalseif it should be dropped
-
combine
CombinesthisSnapshotFilterwith the giveotherfilter in an "AND" operation, effectively validating whether both returntrueon aallow(DomainEventData)call of each.- Parameters:
other- anotherSnapshotFilterinstance to combine withthisfilter in an "AND" operation- Returns:
- a new
SnapshotFiltercombining thethisandotherfilters in an "AND" operation
-
allowAll
ASnapshotFilterimplementation which allows all snapshots.- Returns:
SnapshotFilterimplementation which allows all snapshots
-
rejectAll
ASnapshotFilterimplementation which rejects all snapshots.- Returns:
- a
SnapshotFilterimplementation which rejects all snapshots
-