Class Aggregate
java.lang.Object
it.polimi.ingsw.server.event_sourcing.Aggregate
- Direct Known Subclasses:
GameState
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidApplies an event, given the Event to apply This method will call using reflection the appropriate handler that manage the eventvoidGenerates the snapshot and saves the Aggregate updated information to the repositoryRestore the aggregate and return the most updated version of the aggregate For doing so, it reconstructs the aggregate from the snapshot and applies the stack of eventsstatic AggregateloadFromUuid(UUID uuid) Returns the updated aggregate based on the UUIDrollback()Recreates the aggregate based on the last snapshot, deletes all the events vit aggregate version > snapshot version
-
Field Details
-
id
-
created
-
repository
-
version
public int version
-
-
Constructor Details
-
Aggregate
public Aggregate() -
Aggregate
-
-
Method Details
-
loadFromUuid
Returns the updated aggregate based on the UUID- Parameters:
uuid- of the Aggregate to recover- Throws:
EventSourcingException- if there is some problem with the handling of the events
-
getCurrentState
Restore the aggregate and return the most updated version of the aggregate For doing so, it reconstructs the aggregate from the snapshot and applies the stack of events- Returns:
- the updated aggregate
- Throws:
EventSourcingException- if there is a problem with the events handlersDBQueryException- if there is a problem with the DB
-
apply
Applies an event, given the Event to apply This method will call using reflection the appropriate handler that manage the event- Parameters:
event- to apply- Throws:
EventSourcingException- if there is some problem finding the appropriate handler
-
createSnapshot
public void createSnapshot()Generates the snapshot and saves the Aggregate updated information to the repository -
rollback
Recreates the aggregate based on the last snapshot, deletes all the events vit aggregate version > snapshot version- Returns:
- the Aggregate Snapshot
-