I
- the type of the entity IDS
- the type of the entity statepublic abstract class AbstractVersionableEntity<I,S extends com.google.protobuf.Message> extends AbstractEntity<I,S> implements VersionableEntity<I,S>, EntityWithLifecycle<I,S>
The entity keeps only its latest state and version information associated with this state.
Entity.GenericParameter
Modifier | Constructor and Description |
---|---|
protected |
AbstractVersionableEntity(I id)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkNotArchived()
Ensures that the entity is not marked as
archived . |
protected void |
checkNotDeleted()
Ensures that the entity is not marked as
deleted . |
boolean |
equals(java.lang.Object o) |
io.spine.server.entity.LifecycleFlags |
getLifecycleFlags()
Obtains current lifecycle flags.
|
io.spine.core.Version |
getVersion()
Obtains the version of the entity.
|
int |
hashCode() |
boolean |
isArchived()
Tests whether the entity is marked as archived.
|
boolean |
isDeleted()
Tests whether the entity is marked as deleted.
|
boolean |
lifecycleFlagsChanged()
Tells whether lifecycle flags of the entity changed since its initialization.
|
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 int |
versionNumber()
Obtains the version number of the entity.
|
com.google.protobuf.Timestamp |
whenModified()
Obtains timestamp of the entity version.
|
checkEntityState, getDefaultState, getId, getState, idAsString, thisClass, toString, updateState
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getState, idAsString
isActive
protected AbstractVersionableEntity(I id)
Upon construction the entity has:
id
- the ID for the new instancejava.lang.IllegalArgumentException
- if the ID is not of one of the
supported typespublic boolean lifecycleFlagsChanged()
EntityWithLifecycle
lifecycleFlagsChanged
in interface EntityWithLifecycle<I,S extends com.google.protobuf.Message>
protected int versionNumber()
public io.spine.core.Version getVersion()
VersionableEntity
getVersion
in interface VersionableEntity<I,S extends com.google.protobuf.Message>
public com.google.protobuf.Timestamp whenModified()
public io.spine.server.entity.LifecycleFlags getLifecycleFlags()
WithLifecycle
getLifecycleFlags
in interface WithLifecycle
public final boolean isArchived()
isArchived
in interface EntityWithLifecycle<I,S extends com.google.protobuf.Message>
isArchived
in interface WithLifecycle
true
if the entity is archived, false
otherwiseprotected void setArchived(boolean archived)
archived
status flag to the passed value.public final boolean isDeleted()
isDeleted
in interface EntityWithLifecycle<I,S extends com.google.protobuf.Message>
isDeleted
in interface WithLifecycle
true
if the entity is deleted, false
otherwiseprotected void setDeleted(boolean deleted)
deleted
status flag to the passed value.protected void checkNotArchived() throws io.spine.server.entity.rejection.CannotModifyArchivedEntity
archived
.io.spine.server.entity.rejection.CannotModifyArchivedEntity
- if the entity in in the archived statusAbstractVersionableEntity.getLifecycleFlags()
,
LifecycleFlags.getArchived()
protected void checkNotDeleted() throws io.spine.server.entity.rejection.CannotModifyDeletedEntity
deleted
.io.spine.server.entity.rejection.CannotModifyDeletedEntity
- if the entity is marked as deleted
AbstractVersionableEntity.getLifecycleFlags()
,
LifecycleFlags.getDeleted()
public boolean equals(java.lang.Object o)
equals
in class AbstractEntity<I,S extends com.google.protobuf.Message>
public int hashCode()
hashCode
in class AbstractEntity<I,S extends com.google.protobuf.Message>