Package org.dellroad.stuff.pobj
Class PersistentObjectEvent<T>
java.lang.Object
java.util.EventObject
org.dellroad.stuff.pobj.PersistentObjectEvent<T>
- Type Parameters:
T
- type of the root persistent object
- All Implemented Interfaces:
Serializable
Notification event emitted by a
PersistentObject
to listeners whenever there is an update to the root object.- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionPersistentObjectEvent
(PersistentObject<T> persistentObject, long version, T oldRoot, T newRoot) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the new root after the update.Get the old root prior to the update.Get thePersistentObject
that originated this event.long
Get the version that this event is associated with.Methods inherited from class java.util.EventObject
toString
-
Constructor Details
-
PersistentObjectEvent
public PersistentObjectEvent(PersistentObject<T> persistentObject, long version, T oldRoot, T newRoot) Constructor.- Parameters:
persistentObject
- source of this eventversion
- the new persistent object version (i.e., the version ofnewRoot
)oldRoot
- previous root object; null if exiting from an empty start periodnewRoot
- updated root object; null if entering an empty stop period
-
-
Method Details
-
getSource
Get thePersistentObject
that originated this event.- Overrides:
getSource
in classEventObject
-
getVersion
public long getVersion()Get the version that this event is associated with. This will be the version of the new root.The
PersistentObject
class always delivers notifications in order, so this number should always increase over time.- Returns:
- new root version number
-
getOldRoot
Get the old root prior to the update.The caller must not modify the returned object, as it is shared among all listeners.
- Returns:
- the old root object; will be null if an empty start period has just ended
-
getNewRoot
Get the new root after the update.The caller must not modify the returned object, as it is shared among all listeners.
- Returns:
- the new root object; will be null if an empty stop period has just started
-