public abstract class TransactionalEntity<I,S extends com.google.protobuf.Message,B extends io.spine.validate.ValidatingBuilder<S,? extends com.google.protobuf.Message.Builder>> extends AbstractEntity<I,S>
Defines a transaction-based mechanism for state, version and lifecycle flags update.
Exposes TransactionalEntity.getBuilder() validating builder} for the state as the only way to modify the state from the descendants.
Modifier | Constructor and Description |
---|---|
protected |
TransactionalEntity(I id)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearRecentHistory()
Clears recent history.
|
protected B |
getBuilder()
Obtains the instance of the state builder.
|
io.spine.server.entity.LifecycleFlags |
getLifecycleFlags()
Obtains the current state of the entity lifecycle flags.
|
protected java.lang.String |
getMissingTxMessage()
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() |
checkEntityState, checkNotArchived, checkNotDeleted, equals, getDefaultState, getId, getState, getVersion, hashCode, idAsString, isArchived, isDeleted, lifecycleFlagsChanged, thisClass, toString, versionNumber, whenModified
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isActive
protected TransactionalEntity(I id)
id
- the ID for the new instancejava.lang.IllegalArgumentException
- if the ID is not of one of the
supported typesprotected RecentHistory recentHistory()
protected void remember(java.lang.Iterable<io.spine.core.Event> events)
protected void clearRecentHistory()
protected B getBuilder()
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 getMissingTxMessage()
protected Transaction<I,? extends TransactionalEntity<I,S,B>,S,B> tx()
protected void setInitialState(S initialState, io.spine.core.Version version)
The execution of this method requires a presence of active transaction.
public 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 com.google.protobuf.Message>
protected void setArchived(boolean archived)
archived
status flag to the passed value.
The execution of this method requires a presence of active transaction.
setArchived
in class AbstractEntity<I,S extends com.google.protobuf.Message>
protected void setDeleted(boolean deleted)
deleted
status flag to the passed value.
The execution of this method requires a presence of active transaction.
setDeleted
in class AbstractEntity<I,S extends com.google.protobuf.Message>