Class EventListenerList.EventListenerIterator<T extends Event>

java.lang.Object
org.apache.commons.configuration2.event.EventListenerList.EventListenerIterator<T>
Type Parameters:
T - the event type
All Implemented Interfaces:
Iterator<EventListener<? super T>>
Enclosing class:
EventListenerList

public static final class EventListenerList.EventListenerIterator<T extends Event> extends Object implements Iterator<EventListener<? super T>>
A special Iterator implementation used by the getEventListenerIterator() method. This iterator returns only listeners compatible with a specified event type. It has a convenience method for invoking the current listener in the iteration with an event.
  • Field Details

    • underlyingIterator

      private final Iterator<EventListenerRegistrationData<?>> underlyingIterator
      The underlying iterator.
    • baseEventType

      private final EventType<T extends Event> baseEventType
      The base event type.
    • acceptedTypes

      private final Set<EventType<?>> acceptedTypes
      The set with accepted event types.
    • nextElement

      private EventListener<? super T extends Event> nextElement
      The next element in the iteration.
  • Constructor Details

  • Method Details

    • castListener

      private EventListener<? super T> castListener(EventListenerRegistrationData<?> regData)
      Extracts the listener from the given data object and performs a cast to the target type. This is safe because it has been checked before that the type is compatible.
      Parameters:
      regData - the data object
      Returns:
      the extracted listener
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T extends Event>
    • initNextElement

      private void initNextElement()
      Determines the next element in the iteration.
    • invokeNext

      public void invokeNext(Event event)
      Obtains the next event listener in this iteration and invokes it with the given event object.
      Parameters:
      event - the event object
      Throws:
      NoSuchElementException - if iteration is at its end
    • invokeNextListenerUnchecked

      private void invokeNextListenerUnchecked(Event event)
      Invokes the next event listener in the iteration without doing a validity check on the event. This method is called internally to avoid duplicate event checks.
      Parameters:
      event - the event object
    • next

      public EventListener<? super T> next()
      Specified by:
      next in interface Iterator<T extends Event>
    • remove

      public void remove()
      This implementation always throws an exception. Removing elements is not supported.
      Specified by:
      remove in interface Iterator<T extends Event>
    • validateEvent

      private void validateEvent(Event event)
      Checks whether the specified event can be passed to an event listener in this iteration. This check is done via the hierarchy of event types.
      Parameters:
      event - the event object
      Throws:
      IllegalArgumentException - if the event is invalid