Class AbstractUniqueEntity<ID extends java.io.Serializable>
- java.lang.Object
-
- org.drdeesw.commons.models.base.entities.AbstractUniqueEntity<ID>
-
- All Implemented Interfaces:
java.io.Serializable,DataTransferObject,UniqueEntity<ID>,UniqueObject<ID>
- Direct Known Subclasses:
AbstractLongUniqueEntity,AbstractNamedUniqueEntity,AbstractStringUniqueEntity,AuthorityEntity,GroupAuthorityEntity
@MappedSuperclass public abstract class AbstractUniqueEntity<ID extends java.io.Serializable> extends java.lang.Object implements UniqueEntity<ID>
Represents a unique object.- Author:
- gary_kephart
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractUniqueEntity()The default constructor.protectedAbstractUniqueEntity(ID id)Constructs an object with the given id.protectedAbstractUniqueEntity(UniqueObject<ID> that)Constructs a copy of the given object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T extends AbstractUniqueEntity<ID>>
Tcast()booleanequals(java.lang.Object obj)booleanequalsWithNullCheck(java.lang.Object value1, java.lang.Object value2)IDgetId()Returns the ID of the object.inthashCode()voidsetId(ID id)java.lang.StringtoString()voidupdate(AbstractUniqueEntity<ID> that)
-
-
-
Constructor Detail
-
AbstractUniqueEntity
protected AbstractUniqueEntity()
The default constructor.
-
AbstractUniqueEntity
protected AbstractUniqueEntity(ID id)
Constructs an object with the given id.- Parameters:
id- the ID of the object to construct
-
AbstractUniqueEntity
protected AbstractUniqueEntity(UniqueObject<ID> that)
Constructs a copy of the given object.- Parameters:
that- the object to copy
-
-
Method Detail
-
cast
protected <T extends AbstractUniqueEntity<ID>> T cast()
- Returns:
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
equalsWithNullCheck
public boolean equalsWithNullCheck(java.lang.Object value1, java.lang.Object value2)- Parameters:
value1-value2-- Returns:
-
getId
public ID getId()
Returns the ID of the object. Subclasses need to specify the Column annotation. The ID annotation is necessary: "You cannot override the [id] non-identifier property from the [...AbstractUniqueObject] base class or MappedSuperclass and make it an identifier in the subclass!" So we should not need it in the subclasses.- Specified by:
getIdin interfaceUniqueObject<ID extends java.io.Serializable>- Returns:
- the unique id of the object.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
setId
public void setId(ID id)
- Specified by:
setIdin interfaceUniqueObject<ID extends java.io.Serializable>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
update
public void update(AbstractUniqueEntity<ID> that)
- Parameters:
that-
-
-