org.itracker.model
Class AbstractEntity

java.lang.Object
  extended by org.itracker.model.AbstractEntity
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Entity>, Entity
Direct Known Subclasses:
Component, Configuration, CustomField, CustomFieldValue, ImportDataModel, Issue, IssueActivity, IssueAttachment, IssueField, IssueHistory, IssueRelation, Language, NameValuePair, Notification, Permission, Project, ProjectScript, Report, SystemConfiguration, User, UserPreferences, Version, WorkflowScript

public abstract class AbstractEntity
extends Object
implements Entity

This is a POJO Business Domain Object. Hibernate Bean.

All entities are Java Beans and should inherit this class to make sure they are Serializable and Cloneable and have the following fields : an id, a creation date and a last modifiation date.

Author:
ready
See Also:
Serialized Form

Nested Class Summary
protected static class AbstractEntity.CreateDateComparator
           
protected static class AbstractEntity.IdComparator
          Compares 2 instances by ID.
protected static class AbstractEntity.LastModifiedDateComparator
          Compares 2 instances by last modified date.
 
Field Summary
static Comparator<AbstractEntity> CREATE_DATE_COMPARATOR
           
static Comparator<Entity> ID_COMPARATOR
           
static Comparator<AbstractEntity> LAST_MODIFIED_DATE_COMPARATOR
           
 
Constructor Summary
AbstractEntity()
          Default constructor (required by Hibernate).
 
Method Summary
 Object clone()
           
 int compareTo(Entity o)
           
 boolean equals(Object obj)
           
 Date getCreateDate()
           
 Integer getId()
          Returns the system ID.
 Date getLastModifiedDate()
           
 int hashCode()
           
 boolean isNew()
          Returns whether this instance represents a new transient instance.
 void setCreateDate(Date dateTime)
          Sets the creation date and time.
 void setId(Integer id)
          Sets this entity's system ID.
 void setLastModifiedDate(Date dateTime)
          Sets the last modification date and time.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_COMPARATOR

public static final Comparator<Entity> ID_COMPARATOR

CREATE_DATE_COMPARATOR

public static final Comparator<AbstractEntity> CREATE_DATE_COMPARATOR

LAST_MODIFIED_DATE_COMPARATOR

public static final Comparator<AbstractEntity> LAST_MODIFIED_DATE_COMPARATOR
Constructor Detail

AbstractEntity

public AbstractEntity()
Default constructor (required by Hibernate).

Method Detail

getId

public Integer getId()
Description copied from interface: Entity
Returns the system ID.

Specified by:
getId in interface Entity
Returns:
ID > 0 for persistent entities, null for transient ones

setId

public void setId(Integer id)
Description copied from interface: Entity
Sets this entity's system ID.

Specified by:
setId in interface Entity
Parameters:
id - ID > 0 for persistent entities, null for transient ones

getCreateDate

public Date getCreateDate()
Specified by:
getCreateDate in interface Entity
Returns:
creation time stamp or null for transient entities

setCreateDate

public void setCreateDate(Date dateTime)
Sets the creation date and time.

The persistence framework automatically sets this property when a new entity is persisted.
Note that the value is managed by the persistence framework and may be generated by the database in the future.

The creation time stamp should never change once initialized.

Specified by:
setCreateDate in interface Entity
Parameters:
dateTime - creation time stamp

getLastModifiedDate

public Date getLastModifiedDate()
Specified by:
getLastModifiedDate in interface Entity
Returns:
last modification time stamp or null for transient entities

setLastModifiedDate

public void setLastModifiedDate(Date dateTime)
Sets the last modification date and time.

The persistence framework automatically sets this property to the same value as the createDate property when persisting a new entity and automatically updates it when saving an existing one.
Note that the value is managed by the persistence framework and may be generated by the database in the future.

Specified by:
setLastModifiedDate in interface Entity
Parameters:
dateTime - last modification time stamp

isNew

public boolean isNew()
Returns whether this instance represents a new transient instance.

Specified by:
isNew in interface Entity
Returns:
true if id is null

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

compareTo

public final int compareTo(Entity o)
Specified by:
compareTo in interface Comparable<Entity>

hashCode

public final int hashCode()
Overrides:
hashCode in class Object


Copyright © 2002-2012 itracker. All Rights Reserved.