org.qi4j.spi.entitystore.helpers
Class DefaultEntityState

java.lang.Object
  extended by org.qi4j.spi.entitystore.helpers.DefaultEntityState
All Implemented Interfaces:
EntityState

public final class DefaultEntityState
extends java.lang.Object
implements EntityState

Standard implementation of EntityState.


Field Summary
protected  java.util.Map<QualifiedName,EntityReference> associations
           
protected  long lastModified
           
protected  java.util.Map<QualifiedName,java.util.List<EntityReference>> manyAssociations
           
protected  java.util.Map<QualifiedName,java.lang.Object> properties
           
protected  EntityStatus status
           
protected  DefaultEntityStoreUnitOfWork unitOfWork
           
protected  java.lang.String version
           
 
Constructor Summary
DefaultEntityState(DefaultEntityStoreUnitOfWork unitOfWork, EntityReference identity, EntityDescriptor entityDescriptor)
           
DefaultEntityState(DefaultEntityStoreUnitOfWork unitOfWork, java.lang.String version, long lastModified, EntityReference identity, EntityStatus status, EntityDescriptor entityDescriptor, java.util.Map<QualifiedName,java.lang.Object> properties, java.util.Map<QualifiedName,EntityReference> associations, java.util.Map<QualifiedName,java.util.List<EntityReference>> manyAssociations)
           
 
Method Summary
 java.util.Map<QualifiedName,EntityReference> associations()
           
 EntityReference associationValueOf(QualifiedName stateName)
           
 void copyTo(DefaultEntityState entityState)
           
 EntityDescriptor entityDescriptor()
           
 EntityReference identity()
          Returns the identity of the entity that this EntityState represents.
 boolean isAssignableTo(java.lang.Class<?> type)
           
 long lastModified()
          Last modified timestamp of the entity.
 java.util.Map<QualifiedName,java.util.List<EntityReference>> manyAssociations()
           
 ManyAssociationState manyAssociationValueOf(QualifiedName stateName)
           
 void markUpdated()
           
 java.util.Map<QualifiedName,java.lang.Object> properties()
           
 java.lang.Object propertyValueOf(QualifiedName stateName)
           
 void remove()
          Remove the entity represented by this EntityState when the unit of work is completed.
 void setAssociationValue(QualifiedName stateName, EntityReference newEntity)
           
 void setPropertyValue(QualifiedName stateName, java.lang.Object newValue)
           
 EntityStatus status()
          The status of this EntityState
 java.lang.String toString()
           
 java.lang.String version()
          Version of the entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

unitOfWork

protected DefaultEntityStoreUnitOfWork unitOfWork

status

protected EntityStatus status

version

protected java.lang.String version

lastModified

protected long lastModified

properties

protected final java.util.Map<QualifiedName,java.lang.Object> properties

associations

protected final java.util.Map<QualifiedName,EntityReference> associations

manyAssociations

protected final java.util.Map<QualifiedName,java.util.List<EntityReference>> manyAssociations
Constructor Detail

DefaultEntityState

public DefaultEntityState(DefaultEntityStoreUnitOfWork unitOfWork,
                          EntityReference identity,
                          EntityDescriptor entityDescriptor)

DefaultEntityState

public DefaultEntityState(DefaultEntityStoreUnitOfWork unitOfWork,
                          java.lang.String version,
                          long lastModified,
                          EntityReference identity,
                          EntityStatus status,
                          EntityDescriptor entityDescriptor,
                          java.util.Map<QualifiedName,java.lang.Object> properties,
                          java.util.Map<QualifiedName,EntityReference> associations,
                          java.util.Map<QualifiedName,java.util.List<EntityReference>> manyAssociations)
Method Detail

version

public final java.lang.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.

propertyValueOf

public java.lang.Object propertyValueOf(QualifiedName stateName)
Specified by:
propertyValueOf in interface EntityState

setPropertyValue

public void setPropertyValue(QualifiedName stateName,
                             java.lang.Object newValue)
Specified by:
setPropertyValue in interface EntityState

associationValueOf

public EntityReference associationValueOf(QualifiedName stateName)
Specified by:
associationValueOf in interface EntityState

setAssociationValue

public void setAssociationValue(QualifiedName stateName,
                                EntityReference newEntity)
Specified by:
setAssociationValue in interface EntityState

manyAssociationValueOf

public ManyAssociationState manyAssociationValueOf(QualifiedName stateName)
Specified by:
manyAssociationValueOf 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

isAssignableTo

public boolean isAssignableTo(java.lang.Class<?> type)
Specified by:
isAssignableTo in interface EntityState

entityDescriptor

public EntityDescriptor entityDescriptor()
Specified by:
entityDescriptor in interface EntityState

properties

public java.util.Map<QualifiedName,java.lang.Object> properties()

associations

public java.util.Map<QualifiedName,EntityReference> associations()

manyAssociations

public java.util.Map<QualifiedName,java.util.List<EntityReference>> manyAssociations()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

markUpdated

public void markUpdated()