I
- the type for IDs of this class of aggregatesS
- the type of the state held by the aggregate partB
- the type of the aggregate part state builderR
- the type of the aggregate rootpublic abstract class AggregatePart<I,S extends com.google.protobuf.Message,B extends io.spine.validate.ValidatingBuilder<S,? extends com.google.protobuf.Message.Builder>,R extends AggregateRoot<I>> extends Aggregate<I,S,B>
Some business logic objects may be big enough. If not all parts of such a business object need to be preserved at the same time as business logic invariants, such an object can be split into several parts.
Each such part would:
AggregatePart
AggregateRepository
In order to access parts of the aggregate AggregateRoot
should be used.
If your business logic cannot be split into parts that can be modified separately,
consider extending Aggregate
instead of several AggregatePart
s.
Aggregate
Modifier and Type | Class and Description |
---|---|
static class |
AggregatePart.GenericParameter
Enumeration of generic type parameters of this class.
|
Modifier | Constructor and Description |
---|---|
protected |
AggregatePart(R root)
Creates a new instance of the aggregate part.
|
Modifier and Type | Method and Description |
---|---|
protected <P extends com.google.protobuf.Message> |
getPartState(java.lang.Class<P> partStateClass)
Obtains a state of another
AggregatePart by its class. |
protected AggregatePartClass<?> |
thisClass()
Obtains model class for this aggregate part.
|
clearRecentHistory, dispatchCommand, getBuilder, getMissingTxMessage, historyBackward, play, versionNumber
expectedDefault, expectedEmpty, expectedNotDefault, expectedNotDefault, expectedNotEmpty, getProducerId, unexpectedValue, unexpectedValue
getLifecycleFlags, recentHistory, remember, setArchived, setDeleted, setInitialState, tx
checkEntityState, checkNotArchived, checkNotDeleted, equals, getDefaultState, getId, getState, getVersion, hashCode, idAsString, isArchived, isDeleted, lifecycleFlagsChanged, toString, whenModified
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getProducerId, getVersion, nothing
isActive
protected AggregatePart(R root)
root
- a root of the aggregate to which this part belongsprotected AggregatePartClass<?> thisClass()
protected <P extends com.google.protobuf.Message> P getPartState(java.lang.Class<P> partStateClass)
AggregatePart
by its class.P
- the type of the part statepartStateClass
- the class of the state of the partjava.lang.IllegalStateException
- if a repository was not found,
or the ID type of the part state does not match
the ID type of the root