Class AbstractTopiaEntity

java.lang.Object
org.nuiton.topia.persistence.internal.AbstractTopiaEntity
All Implemented Interfaces:
Serializable, TopiaEntity

public abstract class AbstractTopiaEntity extends Object implements TopiaEntity
Base class of each entity. It contains the common attributes and a part of the entities event support. This class does not realize ListenableTopiaEntity but it implements its methods to lighten base implementation.
Author:
Benjamin Poussin - poussin@codelutin.com, Arnaud Thimel (Code Lutin)
See Also:
  • Field Details

    • DEFAULT_INSTANCE

      protected static final TopiaFiresSupport DEFAULT_INSTANCE
      Default instance used as fallback by the entities if they are out of a ToPIA runtime scope.
    • topiaId

      protected String topiaId
    • topiaVersion

      protected long topiaVersion
    • topiaCreateDate

      protected Date topiaCreateDate
    • deleted

      protected transient boolean deleted
    • firesSupport

      protected transient WeakReference<TopiaFiresSupport> firesSupport
      A potential instance that may be injected by the Dao or retrieved in a contextable entity. The TopiaFiresSupport instance can be linked to the TopiaPersistenceContext instance, thus its life cycle may be shorter than the entity. This is why it is kept as a WeakReference. If not present, the entity will use the DEFAULT_INSTANCE as a fallback TopiaFiresSupport.
    • preReadListeners

      protected transient VetoableChangeSupport preReadListeners
    • postReadListeners

      protected transient PropertyChangeSupport postReadListeners
    • preWriteListeners

      protected transient VetoableChangeSupport preWriteListeners
    • postWriteListeners

      protected transient PropertyChangeSupport postWriteListeners
  • Constructor Details

    • AbstractTopiaEntity

      public AbstractTopiaEntity()
  • Method Details

    • setFiresSupport

      public void setFiresSupport(TopiaFiresSupport firesSupport)
    • getFiresSupportOrNull

      protected TopiaFiresSupport getFiresSupportOrNull()
    • getFiresSupport

      protected TopiaFiresSupport getFiresSupport()
    • getPostReadListeners

      protected PropertyChangeSupport getPostReadListeners(boolean create)
      Initialize postReadListeners at first use or after deserialisation.
      Parameters:
      create - indicates if the PropertyChangeSupport can be created if it does not exist
      Returns:
      postReadListeners
    • getPostWriteListeners

      protected PropertyChangeSupport getPostWriteListeners(boolean create)
      Initialize postWriteListeners at first use or after deserialisation.
      Parameters:
      create - indicates if the PropertyChangeSupport can be created if it does not exist
      Returns:
      postWriteListeners
    • getPreReadListeners

      protected VetoableChangeSupport getPreReadListeners(boolean create)
      Initialize preReadListeners at first use or after deserialisation.
      Parameters:
      create - indicates if the VetoableChangeSupport can be created if it does not exist
      Returns:
      readVetoables
    • getPreWriteListeners

      protected VetoableChangeSupport getPreWriteListeners(boolean create)
      Initialize preWriteListeners at first use or after deserialisation.
      Parameters:
      create - indicates if the VetoableChangeSupport can be created if it does not exist
      Returns:
      preWriteListeners
    • getTopiaId

      public String getTopiaId()
      Description copied from interface: TopiaEntity
      Unique technical Id of the entity. This id contains the fully qualified name of the entity interface. This id also has an index and is used to uniquely identify the entity in the database.
      Specified by:
      getTopiaId in interface TopiaEntity
      Returns:
      the technical Id of the entity
    • setTopiaId

      public void setTopiaId(String v)
      Description copied from interface: TopiaEntity
      Set the technical id of the entity. Make sure to use this method only for copy. The technical id is generated by ToPIA when the entity is persisted using the TopiaDao.create() methods.
      Specified by:
      setTopiaId in interface TopiaEntity
      Parameters:
      v - technical id to set
    • getTopiaVersion

      public long getTopiaVersion()
      Description copied from interface: TopiaEntity
      Technical property to keep versionning of the entity. The version is incremented on each change of the entity.
      Specified by:
      getTopiaVersion in interface TopiaEntity
      Returns:
      the current version of the entity
    • setTopiaVersion

      public void setTopiaVersion(long v)
      Description copied from interface: TopiaEntity
      Set the technical version of the entity. Make sure to use this method only for copy. The version is automatically incremented on entity changes.
      Specified by:
      setTopiaVersion in interface TopiaEntity
      Parameters:
      v - technical version to set
    • getTopiaCreateDate

      public Date getTopiaCreateDate()
      Description copied from interface: TopiaEntity
      Technical date creation of the entity. This date doesn't change through time and was initialized on entity creation when using the TopiaDao.create() methods.
      Specified by:
      getTopiaCreateDate in interface TopiaEntity
      Returns:
      the creation date of the entity
    • setTopiaCreateDate

      public void setTopiaCreateDate(Date topiaCreateDate)
      Description copied from interface: TopiaEntity
      Set the technical creation date of the entity. Make sure to use this method only for copy. This date is immutable and was created on entity creation.
      Specified by:
      setTopiaCreateDate in interface TopiaEntity
      Parameters:
      topiaCreateDate - technical create date to set
    • isPersisted

      public boolean isPersisted()
      Description copied from interface: TopiaEntity
      This method must be used to know if the current entity is present on the persistent support. If the entity is not yet persisted or if the entity has been removed, this method will return false.
      Specified by:
      isPersisted in interface TopiaEntity
      Returns:
      true if the entity is persisted and not yet deleted
    • isDeleted

      public boolean isDeleted()
      Specified by:
      isDeleted in interface TopiaEntity
      Returns:
      Is the entity was removed from persistent support ?
    • notifyDeleted

      public void notifyDeleted()
      Description copied from interface: TopiaEntity
      Notifies the current entity instance than it has been removed from the persistent support.
      Specified by:
      notifyDeleted in interface TopiaEntity
    • hashCode

      public int hashCode()
      We are using the topiaCreateDate for the hashCode because it does not change through time.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • fireOnPreRead

      protected void fireOnPreRead(String propertyName, Object value)
    • fireOnPostRead

      protected void fireOnPostRead(String propertyName, Object value)
    • fireOnPostRead

      protected void fireOnPostRead(String propertyName, int index, Object value)
    • fireOnPreWrite

      protected void fireOnPreWrite(String propertyName, Object oldValue, Object newValue)
    • fireOnPostWrite

      protected void fireOnPostWrite(String propertyName, Object oldValue, Object newValue)
    • fireOnPostWrite

      protected void fireOnPostWrite(String propertyName, int index, Object oldValue, Object newValue)
    • addPreReadListener

      public void addPreReadListener(String propertyName, VetoableChangeListener listener)
    • addPreReadListener

      public void addPreReadListener(VetoableChangeListener listener)
    • removePreReadListener

      public void removePreReadListener(String propertyName, VetoableChangeListener listener)
    • removePreReadListener

      public void removePreReadListener(VetoableChangeListener listener)
    • addPostReadListener

      public void addPostReadListener(String propertyName, PropertyChangeListener listener)
    • addPostReadListener

      public void addPostReadListener(PropertyChangeListener listener)
    • removePostReadListener

      public void removePostReadListener(String propertyName, PropertyChangeListener listener)
    • removePostReadListener

      public void removePostReadListener(PropertyChangeListener listener)
    • addPreWriteListener

      public void addPreWriteListener(String propertyName, VetoableChangeListener listener)
    • addPreWriteListener

      public void addPreWriteListener(VetoableChangeListener listener)
    • removePreWriteListener

      public void removePreWriteListener(String propertyName, VetoableChangeListener listener)
    • removePreWriteListener

      public void removePreWriteListener(VetoableChangeListener listener)
    • addPostWriteListener

      public void addPostWriteListener(String propertyName, PropertyChangeListener listener)
    • addPostWriteListener

      public void addPostWriteListener(PropertyChangeListener listener)
    • removePostWriteListener

      public void removePostWriteListener(String propertyName, PropertyChangeListener listener)
    • removePostWriteListener

      public void removePostWriteListener(PropertyChangeListener listener)
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
    • addPropertyChangeListener

      public void addPropertyChangeListener(String property, PropertyChangeListener listener)
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
    • removePropertyChangeListener

      public void removePropertyChangeListener(String property, PropertyChangeListener listener)