Package org.silverpeas.core.persistence
Class EntityReference<T>
- java.lang.Object
- 
- org.silverpeas.core.persistence.EntityReference<T>
 
- 
- Type Parameters:
- T- the type of the entity on which this reference is about.
 - Direct Known Subclasses:
- CalendarReference,- PublicationNoteReference,- UserReference,- UserSessionReference
 
 public abstract class EntityReference<T> extends Object A reference to an entity in Silverpeas. An entity is a business object in Silverpeas that is persisted in a data source. Some times, instead of referring a peculiar entity, an object can refer an entity whatever its type; this is why it refers such objects with anEntityReferenceinstance. The type of the entity referred by a such reference is defined by the type of the reference itself; An entity reference must be concrete and its type carries the type of the entity it is upon. For example, you can implement a reference to a user by naming itUserReference<UserDetail>.- Author:
- mmoquillon
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringUNKNOWN_TYPE
 - 
Constructor SummaryConstructors Constructor Description EntityReference(String id)Constructs a reference targeting the entity identified by the specified unique identifier.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(Object anotherReference)abstract TgetEntity()Gets the instance of the entity targeted by this reference.StringgetId()Gets the unique identifier of the entity referred by this reference.StringgetType()Gets the name of the entity type referred by this reference.static StringgetType(Class aClass)Extracts automatically the type from aClass.static StringgetType(String classSimpleName)Extracts automatically the type from a simple name ofClass.inthashCode()
 
- 
- 
- 
Field Detail- 
UNKNOWN_TYPEpublic static final String UNKNOWN_TYPE - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
EntityReferencepublic EntityReference(String id) Constructs a reference targeting the entity identified by the specified unique identifier.- Parameters:
- id- the unique identifier of the entity to refer.
 
 
- 
 - 
Method Detail- 
getIdpublic final String getId() Gets the unique identifier of the entity referred by this reference.- Returns:
- the unique identifier of the entity as a String.
 
 - 
getTypepublic final String getType() Gets the name of the entity type referred by this reference. The name is returned in upper case. The name is different from the class name of both of the reference itself and of the referred entity, so any class name change shouldn't impact the type name here. The type name is in fact derived from the class name of the entity but by removing all extra technical terms in order to keep only the meaningful name of the business object. For example, for the entityUserDetail, only the termUseris kept and then set in upper case. Not all technical terms are detected; for instance, only the following technical terms are taken into account: Silverpeas, Detail, Interface, Silver, Content, Full, and Complete.- Returns:
- the meaningful name in upper case of the type of the referred entity.
 
 - 
getTypepublic static String getType(Class aClass) Extracts automatically the type from aClass.- Parameters:
- aClass- the class
- Returns:
- the meaningful name in upper case of the type of the referred entity.
 
 - 
getTypepublic static String getType(String classSimpleName) Extracts automatically the type from a simple name ofClass.- Parameters:
- classSimpleName- the class simple name
- Returns:
- the meaningful name in upper case of the type of the referred entity.
 
 - 
getEntitypublic abstract T getEntity() Gets the instance of the entity targeted by this reference.- Returns:
- the entity identified by this reference.
 
 
- 
 
-