Class 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 an EntityReference instance. 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 it UserReference<UserDetail>.
    Author:
    mmoquillon
    • Constructor Detail

      • EntityReference

        public 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

      • getId

        public final String getId()
        Gets the unique identifier of the entity referred by this reference.
        Returns:
        the unique identifier of the entity as a String.
      • getType

        public 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 entity UserDetail, only the term User is 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.
      • getType

        public static String getType​(Class aClass)
        Extracts automatically the type from a Class.
        Parameters:
        aClass - the class
        Returns:
        the meaningful name in upper case of the type of the referred entity.
      • getType

        public static String getType​(String classSimpleName)
        Extracts automatically the type from a simple name of Class.
        Parameters:
        classSimpleName - the class simple name
        Returns:
        the meaningful name in upper case of the type of the referred entity.
      • getEntity

        public abstract T getEntity()
        Gets the instance of the entity targeted by this reference.
        Returns:
        the entity identified by this reference.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object anotherReference)
        Overrides:
        equals in class Object