net.sourceforge.domian.entity
Class AbstractEntity

java.lang.Object
  extended by net.sourceforge.domian.entity.AbstractEntity
All Implemented Interfaces:
Entity
Direct Known Subclasses:
AbstractRandomIntegerEntity, AbstractRandomLongEntity, AbstractUUIDEntity

public abstract class AbstractEntity
extends java.lang.Object
implements Entity

Abstract class for all entity objects, ensuring consistent/unchanging equals/hashCode methods, not influenced by mutable state.

Also, the time of creation is recorded and available.

Since:
0.4
Author:
Eirik Torske

Field Summary
protected  java.lang.Long timeOfCreation
           
protected  java.lang.Integer version
          For possible use of RDBMS optimistic locking.
 
Constructor Summary
AbstractEntity()
           
 
Method Summary
protected  void doWarnLog(java.lang.String message)
           
 boolean equals(java.lang.Object otherObject)
           
 java.lang.Long getTimeOfCreation()
          An entity object always originates from one specific moment in time.
 java.lang.Integer getVersion()
           
 int hashCode()
           
 java.lang.Boolean isEntity()
           
 java.lang.Boolean isValueObject()
           
 void setVersion(java.lang.Integer version)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sourceforge.domian.entity.Entity
getEntityId
 

Field Detail

timeOfCreation

protected final java.lang.Long timeOfCreation

version

protected java.lang.Integer version
For possible use of RDBMS optimistic locking.

Constructor Detail

AbstractEntity

public AbstractEntity()
Method Detail

getVersion

public java.lang.Integer getVersion()

setVersion

public void setVersion(java.lang.Integer version)

getTimeOfCreation

public final java.lang.Long getTimeOfCreation()
Description copied from interface: Entity
An entity object always originates from one specific moment in time.

Specified by:
getTimeOfCreation in interface Entity
Returns:
the time of creation of this entity, in milliseconds after 01.01.1970

isEntity

public final java.lang.Boolean isEntity()

isValueObject

public final java.lang.Boolean isValueObject()

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public final boolean equals(java.lang.Object otherObject)
Overrides:
equals in class java.lang.Object

doWarnLog

protected void doWarnLog(java.lang.String message)

toString

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


Copyright © 2006-2010. All Rights Reserved.