public class EventDispatchChainImpl extends java.lang.Object implements EventDispatchChain
Modifier and Type | Field and Description |
---|---|
private int |
activeCount |
private static int |
CAPACITY_GROWTH_FACTOR
Must be a power of two.
|
private EventDispatcher[] |
dispatchers |
private int |
headIndex |
private int[] |
nextLinks |
private int |
reservedCount |
private int |
tailIndex |
Constructor and Description |
---|
EventDispatchChainImpl() |
Modifier and Type | Method and Description |
---|---|
EventDispatchChain |
append(EventDispatcher eventDispatcher)
Appends the specified
EventDispatcher to this chain. |
Event |
dispatchEvent(Event event)
Dispatches the specified event through this
EventDispatchChain . |
private void |
ensureCapacity(int size) |
private void |
insertFirst(EventDispatcher eventDispatcher) |
EventDispatchChain |
prepend(EventDispatcher eventDispatcher)
Prepends the specified
EventDispatcher to this chain. |
void |
reset() |
private static final int CAPACITY_GROWTH_FACTOR
private EventDispatcher[] dispatchers
private int[] nextLinks
private int reservedCount
private int activeCount
private int headIndex
private int tailIndex
public void reset()
public EventDispatchChain append(EventDispatcher eventDispatcher)
EventDispatchChain
EventDispatcher
to this chain. Returns a
reference to the chain with the appended element.
The caller shouldn't assume that this EventDispatchChain
remains
unchanged nor that the returned value will reference a different chain
after the call. All this depends on the EventDispatchChain
implementation.
So the call should be always done in the following form:
chain = chain.append(eventDispatcher);
append
in interface EventDispatchChain
eventDispatcher
- the EventDispatcher
to append to the
chainpublic EventDispatchChain prepend(EventDispatcher eventDispatcher)
EventDispatchChain
EventDispatcher
to this chain. Returns a
reference to the chain with the prepended element.
The caller shouldn't assume that this EventDispatchChain
remains
unchanged nor that the returned value will reference a different chain
after the call. All this depends on the EventDispatchChain
implementation.
So the call should be always done in the following form:
chain = chain.prepend(eventDispatcher);
prepend
in interface EventDispatchChain
eventDispatcher
- the EventDispatcher
to prepend to the
chainpublic Event dispatchEvent(Event event)
EventDispatchChain
EventDispatchChain
.
The return value represents the event after processing done by the chain.
If further processing is to be done after the call the event referenced
by the return value should be used instead of the original event. In the
case the event is fully handled / consumed in the chain the returned
value is null
and no further processing should be done with that
event.dispatchEvent
in interface EventDispatchChain
event
- the event to dispatchnull
if the event had been fully
handled / consumedprivate void insertFirst(EventDispatcher eventDispatcher)
private void ensureCapacity(int size)