Class AbstractTopiaEntity
java.lang.Object
org.nuiton.topia.persistence.internal.AbstractTopiaEntity
- All Implemented Interfaces:
Serializable,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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final TopiaFiresSupportDefault instance used as fallback by the entities if they are out of a ToPIA runtime scope.protected booleanprotected WeakReference<TopiaFiresSupport>A potential instance that may be injected by the Dao or retrieved in a contextable entity.protected PropertyChangeSupportprotected PropertyChangeSupportprotected VetoableChangeSupportprotected VetoableChangeSupportprotected Dateprotected Stringprotected longFields inherited from interface org.nuiton.topia.persistence.TopiaEntity
AGGREGATE, COMPOSITE, PROPERTY_TOPIA_CREATE_DATE, PROPERTY_TOPIA_ID, PROPERTY_TOPIA_VERSION, TOPIA_CREATE_DATE, TOPIA_ID, TOPIA_VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPostReadListener(PropertyChangeListener listener) voidaddPostReadListener(String propertyName, PropertyChangeListener listener) voidaddPostWriteListener(PropertyChangeListener listener) voidaddPostWriteListener(String propertyName, PropertyChangeListener listener) voidaddPreReadListener(VetoableChangeListener listener) voidaddPreReadListener(String propertyName, VetoableChangeListener listener) voidaddPreWriteListener(VetoableChangeListener listener) voidaddPreWriteListener(String propertyName, VetoableChangeListener listener) voidvoidaddPropertyChangeListener(String property, PropertyChangeListener listener) booleanprotected voidfireOnPostRead(String propertyName, int index, Object value) protected voidfireOnPostRead(String propertyName, Object value) protected voidfireOnPostWrite(String propertyName, int index, Object oldValue, Object newValue) protected voidfireOnPostWrite(String propertyName, Object oldValue, Object newValue) protected voidfireOnPreRead(String propertyName, Object value) protected voidfireOnPreWrite(String propertyName, Object oldValue, Object newValue) protected TopiaFiresSupportprotected TopiaFiresSupportprotected PropertyChangeSupportgetPostReadListeners(boolean create) InitializepostReadListenersat first use or after deserialisation.protected PropertyChangeSupportgetPostWriteListeners(boolean create) InitializepostWriteListenersat first use or after deserialisation.protected VetoableChangeSupportgetPreReadListeners(boolean create) InitializepreReadListenersat first use or after deserialisation.protected VetoableChangeSupportgetPreWriteListeners(boolean create) InitializepreWriteListenersat first use or after deserialisation.Technical date creation of the entity.Unique technical Id of the entity.longTechnical property to keep versionning of the entity.inthashCode()We are using thetopiaCreateDatefor the hashCode because it does not change through time.booleanbooleanThis method must be used to know if the current entity is present on the persistent support.voidNotifies the current entity instance than it has been removed from the persistent support.voidremovePostReadListener(PropertyChangeListener listener) voidremovePostReadListener(String propertyName, PropertyChangeListener listener) voidvoidremovePostWriteListener(String propertyName, PropertyChangeListener listener) voidremovePreReadListener(VetoableChangeListener listener) voidremovePreReadListener(String propertyName, VetoableChangeListener listener) voidremovePreWriteListener(VetoableChangeListener listener) voidremovePreWriteListener(String propertyName, VetoableChangeListener listener) voidvoidremovePropertyChangeListener(String property, PropertyChangeListener listener) voidsetFiresSupport(TopiaFiresSupport firesSupport) voidsetTopiaCreateDate(Date topiaCreateDate) Set the technical creationdateof the entity.voidsetTopiaId(String v) Set the technicalidof the entity.voidsetTopiaVersion(long v) Set the technicalversionof the entity.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuiton.topia.persistence.TopiaEntity
accept
-
Field Details
-
DEFAULT_INSTANCE
Default instance used as fallback by the entities if they are out of a ToPIA runtime scope. -
topiaId
-
topiaVersion
protected long topiaVersion -
topiaCreateDate
-
deleted
protected transient boolean deleted -
firesSupport
A potential instance that may be injected by the Dao or retrieved in a contextable entity. The TopiaFiresSupport instance can be linked to theTopiaPersistenceContextinstance, thus its life cycle may be shorter than the entity. This is why it is kept as aWeakReference. If not present, the entity will use theDEFAULT_INSTANCEas a fallback TopiaFiresSupport. -
preReadListeners
-
postReadListeners
-
preWriteListeners
-
postWriteListeners
-
-
Constructor Details
-
AbstractTopiaEntity
public AbstractTopiaEntity()
-
-
Method Details
-
setFiresSupport
-
getFiresSupportOrNull
-
getFiresSupport
-
getPostReadListeners
InitializepostReadListenersat first use or after deserialisation.- Parameters:
create- indicates if the PropertyChangeSupport can be created if it does not exist- Returns:
- postReadListeners
-
getPostWriteListeners
InitializepostWriteListenersat first use or after deserialisation.- Parameters:
create- indicates if the PropertyChangeSupport can be created if it does not exist- Returns:
- postWriteListeners
-
getPreReadListeners
InitializepreReadListenersat first use or after deserialisation.- Parameters:
create- indicates if the VetoableChangeSupport can be created if it does not exist- Returns:
- readVetoables
-
getPreWriteListeners
InitializepreWriteListenersat first use or after deserialisation.- Parameters:
create- indicates if the VetoableChangeSupport can be created if it does not exist- Returns:
- preWriteListeners
-
getTopiaId
Description copied from interface:TopiaEntityUnique 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:
getTopiaIdin interfaceTopiaEntity- Returns:
- the technical Id of the entity
-
setTopiaId
Description copied from interface:TopiaEntitySet the technicalidof the entity. Make sure to use this method only for copy. The technical id is generated by ToPIA when the entity is persisted using theTopiaDao.create()methods.- Specified by:
setTopiaIdin interfaceTopiaEntity- Parameters:
v- technical id to set
-
getTopiaVersion
public long getTopiaVersion()Description copied from interface:TopiaEntityTechnical property to keep versionning of the entity. The version is incremented on each change of the entity.- Specified by:
getTopiaVersionin interfaceTopiaEntity- Returns:
- the current version of the entity
-
setTopiaVersion
public void setTopiaVersion(long v) Description copied from interface:TopiaEntitySet the technicalversionof the entity. Make sure to use this method only for copy. The version is automatically incremented on entity changes.- Specified by:
setTopiaVersionin interfaceTopiaEntity- Parameters:
v- technical version to set
-
getTopiaCreateDate
Description copied from interface:TopiaEntityTechnical date creation of the entity. This date doesn't change through time and was initialized on entity creation when using theTopiaDao.create()methods.- Specified by:
getTopiaCreateDatein interfaceTopiaEntity- Returns:
- the creation date of the entity
-
setTopiaCreateDate
Description copied from interface:TopiaEntitySet the technical creationdateof the entity. Make sure to use this method only for copy. This date is immutable and was created on entity creation.- Specified by:
setTopiaCreateDatein interfaceTopiaEntity- Parameters:
topiaCreateDate- technical create date to set
-
isPersisted
public boolean isPersisted()Description copied from interface:TopiaEntityThis 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:
isPersistedin interfaceTopiaEntity- Returns:
- true if the entity is persisted and not yet deleted
-
isDeleted
public boolean isDeleted()- Specified by:
isDeletedin interfaceTopiaEntity- Returns:
- Is the entity was removed from persistent support ?
-
notifyDeleted
public void notifyDeleted()Description copied from interface:TopiaEntityNotifies the current entity instance than it has been removed from the persistent support.- Specified by:
notifyDeletedin interfaceTopiaEntity
-
hashCode
public int hashCode()We are using thetopiaCreateDatefor the hashCode because it does not change through time. -
equals
-
fireOnPreRead
-
fireOnPostRead
-
fireOnPostRead
-
fireOnPreWrite
-
fireOnPostWrite
-
fireOnPostWrite
-
addPreReadListener
-
addPreReadListener
-
removePreReadListener
-
removePreReadListener
-
addPostReadListener
-
addPostReadListener
-
removePostReadListener
-
removePostReadListener
-
addPreWriteListener
-
addPreWriteListener
-
removePreWriteListener
-
removePreWriteListener
-
addPostWriteListener
-
addPostWriteListener
-
removePostWriteListener
-
removePostWriteListener
-
addPropertyChangeListener
-
addPropertyChangeListener
-
removePropertyChangeListener
-
removePropertyChangeListener
-