Aggregate<TEvent extends Object, TValue extends Object, TId extends AggregateId, TState extends AggregateState<TValue> > class
abstract
Base class for implementing a model within a specific domain
- Type parameter
TState
- AggregateState.value type
Constructors
- Aggregate(TId id, TState original)
-
Default constructor that set
initial
state. Must be called by subclasses.
Properties
-
changes
→ AggregateEventList<
TEvent> -
Get list of pending changes Events folded into current state
no setter
- current → TState
-
AggregateState before first Event
applied locally. Is always equal to original
after load.
no setter
- currentVersion → int
-
The current version of AggregateState. Is
incremented each time an event is folded
onto the state. If currentVersion is
greater than originalVersion this implies
that there are changes made locally.
no setter
- expectedVersion → ExpectedStreamVersion
-
Get ExpectedStreamVersion on next AggregateStore.save
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → TId
-
Get unique AggregateId of type
TId
final - isChanged → bool
-
Check if local changes exists
no setter
- original → TState
-
AggregateState after last Event
applied or folded onto it. Is always equal to
original after creation, load, commit
and rollback.
no setter
- originalVersion → int
-
The aggregate version got from AggregateStore
on last load. Used for optimistic concurrency
checks to ensure that there were no changed made
to the AggregateState since last load.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
apply(
TEvent event) → AggregateStateResult< TEvent, TValue, TId, TState> -
Apply
event
to current state. If successful the event is added to changes and current version is incremented by 1. -
commit(
) → AggregateStateResult< TEvent, TValue, TId, TState> - Commit local changes to original state.
-
ensureDoesntExists(
) → void - Subclasses of Aggregate should use this method to ensure that is is operating on a new Aggregate.
-
ensureExists(
) → void - Subclasses of Aggregate should use this method to ensure that is is operating on an existing Aggregate.
-
fold(
TEvent event) → AggregateStateResult< TEvent, TValue, TId, TState> -
Fold given
event
on current state. -
load(
Iterable< TEvent> events) → AggregateStateResult<TEvent, TValue, TId, TState> -
Load current state from given
events
. If aggregate is already loaded or changed, an DomainException is thrown. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
rollback(
) → AggregateStateResult< TEvent, TValue, TId, TState> - Rollback local changes to original state.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited