com.h3c.util.event

## Class AbstractEventSink<E,L>

- java.lang.Object
- - com.h3c.util.event.AbstractEventSink<E,L>

- Type Parameters:
    `E` - event class
    `L` - listener class
  All Implemented Interfaces:
    EventSink

      public abstract class AbstractEventSink<E,L>
      extends Object
      implements EventSink

  Abstraction of an event sink suitable as a base implementation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CopyOnWriteArraySet<L>` | `listeners` Set of our listeners.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractEventSink()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListener(L listener)` Adds a new listener.
    `protected abstract void` | `dispatch(E event, L listener)` Dispatches an event to the specified listener.
    `void` | `dispatch(Event event)` Dispatches the specified event to all listeners or delegates.
    `Set<L>` | `getListeners()` Gets all registered listeners.
    `void` | `removeListener(L listener)` Removes the specified listener.

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### listeners

          protected final CopyOnWriteArraySet<L> listeners

      Set of our listeners.

  - ### Constructor Detail

    - #### AbstractEventSink

          public AbstractEventSink()

  - ### Method Detail

    - #### addListener

          public void addListener(L listener)

      Adds a new listener.
      Parameters:
        `listener` - listener to be added

    - #### removeListener

          public void removeListener(L listener)

      Removes the specified listener.
      Parameters:
        `listener` - listener to be removed

    - #### getListeners

          public Set<L> getListeners()

      Gets all registered listeners.
      Returns:
        set of registered listeners

    - #### dispatch

          protected abstract void dispatch(E event,
                      L listener)

      Dispatches an event to the specified listener.
      Parameters:
        `event` - event to be dispatched
        `listener` - target listener

    - #### dispatch

          public void dispatch(Event event)

      Description copied from interface: `EventSink`
      Dispatches the specified event to all listeners or delegates.
      Specified by:
        `dispatch` in interface `EventSink`
      Parameters:
        `event` - event data

Copyright © 2014. All Rights Reserved.