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 Summary
FieldsModifier and TypeFieldDescriptionThe set with accepted event types.The base event type.private EventListener
<? super T> The next element in the iteration.private final Iterator
<EventListenerRegistrationData<?>> The underlying iterator. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
EventListenerIterator
(Iterator<EventListenerRegistrationData<?>> it, EventType<T> base) -
Method Summary
Modifier and TypeMethodDescriptionprivate EventListener
<? super T> castListener
(EventListenerRegistrationData<?> regData) Extracts the listener from the given data object and performs a cast to the target type.boolean
hasNext()
private void
Determines the next element in the iteration.void
invokeNext
(Event event) Obtains the next event listener in this iteration and invokes it with the given event object.private void
invokeNextListenerUnchecked
(Event event) Invokes the next event listener in the iteration without doing a validity check on the event.EventListener
<? super T> next()
void
remove()
This implementation always throws an exception.private void
validateEvent
(Event event) Checks whether the specified event can be passed to an event listener in this iteration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
underlyingIterator
The underlying iterator. -
baseEventType
The base event type. -
acceptedTypes
The set with accepted event types. -
nextElement
The next element in the iteration.
-
-
Constructor Details
-
EventListenerIterator
-
-
Method Details
-
castListener
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() -
initNextElement
private void initNextElement()Determines the next element in the iteration. -
invokeNext
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
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
-
remove
public void remove()This implementation always throws an exception. Removing elements is not supported. -
validateEvent
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
-