org.qi4j.spi.entitystore.helpers
Class DefaultEntityState
java.lang.Object
org.qi4j.spi.entitystore.helpers.DefaultEntityState
- All Implemented Interfaces:
- Serializable, EntityState
public final class DefaultEntityState
- extends Object
- implements EntityState, Serializable
Standard implementation of EntityState.
- See Also:
- Serialized Form
Constructor Summary |
DefaultEntityState(DefaultEntityStoreUnitOfWork unitOfWork,
EntityReference identity,
EntityDescriptor entityDescriptor)
|
DefaultEntityState(DefaultEntityStoreUnitOfWork unitOfWork,
String version,
long lastModified,
EntityReference identity,
EntityStatus status,
EntityDescriptor entityDescriptor,
Map<QualifiedName,Object> properties,
Map<QualifiedName,EntityReference> associations,
Map<QualifiedName,List<EntityReference>> manyAssociations,
Map<QualifiedName,Map<String,EntityReference>> namedAssociations)
|
unitOfWork
protected DefaultEntityStoreUnitOfWork unitOfWork
status
protected EntityStatus status
version
protected String version
lastModified
protected long lastModified
properties
protected final Map<QualifiedName,Object> properties
associations
protected final Map<QualifiedName,EntityReference> associations
manyAssociations
protected final Map<QualifiedName,List<EntityReference>> manyAssociations
namedAssociations
protected final Map<QualifiedName,Map<String,EntityReference>> namedAssociations
DefaultEntityState
public DefaultEntityState(DefaultEntityStoreUnitOfWork unitOfWork,
EntityReference identity,
EntityDescriptor entityDescriptor)
DefaultEntityState
public DefaultEntityState(DefaultEntityStoreUnitOfWork unitOfWork,
String version,
long lastModified,
EntityReference identity,
EntityStatus status,
EntityDescriptor entityDescriptor,
Map<QualifiedName,Object> properties,
Map<QualifiedName,EntityReference> associations,
Map<QualifiedName,List<EntityReference>> manyAssociations,
Map<QualifiedName,Map<String,EntityReference>> namedAssociations)
version
public final String version()
- Description copied from interface:
EntityState
- Version of the entity. This is managed by the EntityStore.
If the underlying EntityStore does not support versioning, then version
must always be set to 0.
- Specified by:
version
in interface EntityState
- Returns:
- version of the entity
lastModified
public long lastModified()
- Description copied from interface:
EntityState
- Last modified timestamp of the entity. This is managed by the EntityStore.
If the underlying EntityStore does not support timestamping, then last modified
must always be set to the current time.
- Specified by:
lastModified
in interface EntityState
- Returns:
- last modified timestamp of the entity, as defined by System.currentTimeMillis()
identity
public EntityReference identity()
- Description copied from interface:
EntityState
- Returns the identity of the entity that this EntityState represents.
- Specified by:
identity
in interface EntityState
- Returns:
- the identity of the entity that this EntityState represents.
getProperty
public Object getProperty(QualifiedName stateName)
- Specified by:
getProperty
in interface EntityState
setProperty
public void setProperty(QualifiedName stateName,
Object newValue)
- Specified by:
setProperty
in interface EntityState
getAssociation
public EntityReference getAssociation(QualifiedName stateName)
- Specified by:
getAssociation
in interface EntityState
setAssociation
public void setAssociation(QualifiedName stateName,
EntityReference newEntity)
- Specified by:
setAssociation
in interface EntityState
getManyAssociation
public ManyAssociationState getManyAssociation(QualifiedName stateName)
- Specified by:
getManyAssociation
in interface EntityState
getNamedAssociation
public NamedAssociationState getNamedAssociation(QualifiedName stateName)
- Specified by:
getNamedAssociation
in interface EntityState
copyTo
public void copyTo(DefaultEntityState entityState)
remove
public void remove()
- Description copied from interface:
EntityState
- Remove the entity represented by this EntityState when the unit of work is completed.
- Specified by:
remove
in interface EntityState
status
public EntityStatus status()
- Description copied from interface:
EntityState
- The status of this EntityState
- Specified by:
status
in interface EntityState
- Returns:
- the status
isOfType
public boolean isOfType(TypeName type)
- Specified by:
isOfType
in interface EntityState
entityDescriptor
public EntityDescriptor entityDescriptor()
- Specified by:
entityDescriptor
in interface EntityState
properties
public Map<QualifiedName,Object> properties()
associations
public Map<QualifiedName,EntityReference> associations()
manyAssociations
public Map<QualifiedName,List<EntityReference>> manyAssociations()
namedAssociations
public Map<QualifiedName,Map<String,EntityReference>> namedAssociations()
toString
public String toString()
- Overrides:
toString
in class Object
markUpdated
public void markUpdated()