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

public class PersistentObjectEvent<T> extends EventObject
Notification event emitted by a PersistentObject to listeners whenever there is an update to the root object.
See Also:
  • Constructor Details

    • PersistentObjectEvent

      public PersistentObjectEvent(PersistentObject<T> persistentObject, long version, T oldRoot, T newRoot)
      Constructor.
      Parameters:
      persistentObject - source of this event
      version - the new persistent object version (i.e., the version of newRoot)
      oldRoot - previous root object; null if exiting from an empty start period
      newRoot - updated root object; null if entering an empty stop period
  • Method Details

    • getSource

      public PersistentObject<T> getSource()
      Get the PersistentObject that originated this event.
      Overrides:
      getSource in class EventObject
    • 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

      public T 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

      public T 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