public abstract class TransactionalEntity<I,S extends io.spine.base.EntityState,B extends io.spine.protobuf.ValidatingBuilder<S>> extends AbstractEntity<I,S>
Defines a transaction-based mechanism for state, version, and lifecycle flags update.
Exposes TransactionalEntity.builder() validating builder} for the state as the only way to modify the state from the descendants.
Entity.GenericParameter
Modifier | Constructor and Description |
---|---|
protected |
TransactionalEntity()
Creates a new instance.
|
protected |
TransactionalEntity(I id)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected B |
builder()
Obtains the instance of the state builder.
|
protected void |
clearRecentHistory()
Clears recent history.
|
io.spine.server.entity.LifecycleFlags |
getLifecycleFlags()
Obtains the current state of the entity lifecycle flags.
|
protected java.lang.String |
missingTxMessage()
Provides error message text for the case of not having an active transaction when a state
modification call is made.
|
protected RecentHistory |
recentHistory()
Obtains recent history of events of this entity.
|
protected void |
remember(java.lang.Iterable<io.spine.core.Event> events)
Adds events to the recent history.
|
protected void |
setArchived(boolean archived)
Sets
archived status flag to the passed value. |
protected void |
setDeleted(boolean deleted)
Sets
deleted status flag to the passed value. |
protected void |
setInitialState(S initialState,
io.spine.core.Version version)
Sets an initial state for the entity.
|
protected Transaction<I,? extends TransactionalEntity<I,S,B>,S,B> |
tx()
Obtains the transaction used for modifying the entity.
|
afterInvoke, at, beforeInvoke, checkEntityState, checkNotArchived, checkNotDeleted, defaultState, equals, hashCode, id, idAsString, isArchived, isDeleted, lifecycleFlagsChanged, state, toString, version, versionNumber, whenModified
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isActive, lifecycleFlags
protected TransactionalEntity()
protected TransactionalEntity(I id)
id
- the ID for the new instanceprotected RecentHistory recentHistory()
protected void remember(java.lang.Iterable<io.spine.core.Event> events)
protected void clearRecentHistory()
protected B builder()
This method must be called only from within an active transaction.
java.lang.IllegalStateException
- if the method is called not within a transactionprotected java.lang.String missingTxMessage()
protected Transaction<I,? extends TransactionalEntity<I,S,B>,S,B> tx()
java.lang.IllegalStateException
- if the entity is not in the modification phaseprotected final void setInitialState(S initialState, io.spine.core.Version version)
The execution of this method requires a presence of active transaction.
public final io.spine.server.entity.LifecycleFlags getLifecycleFlags()
If the transaction is in progress, returns the lifecycle flags value for the transaction.
getLifecycleFlags
in interface WithLifecycle
getLifecycleFlags
in class AbstractEntity<I,S extends io.spine.base.EntityState>
WithLifecycle.lifecycleFlags()
protected final void setArchived(boolean archived)
archived
status flag to the passed value.
The execution of this method requires an active transaction.
setArchived
in class AbstractEntity<I,S extends io.spine.base.EntityState>
protected final void setDeleted(boolean deleted)
deleted
status flag to the passed value.
The execution of this method requires an active transaction.
setDeleted
in class AbstractEntity<I,S extends io.spine.base.EntityState>