Module org.apache.sis.storage
Package org.apache.sis.storage.event

# Class CascadedStoreEvent<E extends CascadedStoreEvent<E>>

Object
EventObject
StoreEvent
CascadedStoreEvent<E>

Type Parameters:
  `E` - the type of the event subclass.

All Implemented Interfaces:
  `Serializable`, `Localized`

Direct Known Subclasses:
  `CloseEvent`

public abstract class CascadedStoreEvent<E extends CascadedStoreEvent<E>> extends StoreEvent
An event which, when occurring on a parent resource, is also fired by all children resources. For example, when an `Aggregate` (typically a data store) is closed, a `CloseEvent` is automatically fired by all resources that are components of the aggregate. This is similar to "cascade delete" in SQL databases.

## Difference between `StoreEvent` and `CascadedStoreEvent`

By default `StoreEvent`s are propagated from children to parents. For example, when a `WarningEvent` occurs in a child resource, all listeners registered on that resource are notified, then all listeners registered on the parent resource, and so forth until the root resource. All those listeners receive the same `WarningEvent` instance, i.e. the event source is always the resource where the warning occurred.

By contrast `CascadedStoreEvent` are fired in the opposite direction, from parent to children. Furthermore, each child creates its own `CascadedStoreEvent`. For example if a `CloseEvent` is fired in a `DataStore`, then it causes all resources of that data store to fire their own `CloseEvent` declaring themselves as the event source.

Since:
  1.3
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class EventObject

  `source`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `CascadedStoreEvent(Resource source)`
  Constructs an event that occurred in the given resource.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract E`
  `forSource(Resource child)`
  Creates a new event of the same type than this event but with a different source.

  ### Methods inherited from class StoreEvent

  `consume, getLocale, getSource, isConsumed`

  ### Methods inherited from class EventObject

  `toString`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### CascadedStoreEvent

    protected CascadedStoreEvent(Resource source)
    Constructs an event that occurred in the given resource.
    Parameters:
      `source` - the resource where the event occurred.
    Throws:
      `IllegalArgumentException` - if the given source is null.

- ## Method Details

  - ### forSource

    protected abstract E forSource(Resource child)
    Creates a new event of the same type than this event but with a different source. This method is invoked for creating the event to be fired by the children of the resource where the original event occurred.
    Parameters:
      `child` - the child resource for which to create the event to cascade.
    Returns:
      an event of the same type than this event but with the given resource.