public void addListener(ChainingListener listener, int index)
    {
        // If there's already an entry for that listener then push it on the existing stack
        // and don't add the listener as an additional listener in the list (since it's already
        // in there). We need to take these steps since the push() methods below will create
        // new instances of listeners which will add themselves in the chain automatically.
        Deque<ChainingListener> stack = this.listeners.get(listener.getClass());
        if (stack == null) {
            stack = new ArrayDeque<>();
            this.listeners.put(listener.getClass(), stack);
            if (index > -1 && index < this.nextListeners.size()) {
                this.nextListeners.add(index, listener.getClass());
            } else {
                this.nextListeners.add(listener.getClass());
            }
        }
        stack.push(listener);
    }
public void addListener ( ChainingListener listener , int index ) { Deque < ChainingListener > stack = this . listeners . get ( listener . getClass ( ) ) ; if ( stack == null ) { stack = new ArrayDeque < > ( ) ; this . listeners . put ( listener . getClass ( ) , stack ) ; if ( index > - 1 && index < this . nextListeners . size ( ) ) { this . nextListeners . add ( index , listener . getClass ( ) ) ; } else { this . nextListeners . add ( listener . getClass ( ) ) ; } } stack . push ( listener ) ; }
@param listener the chaining listener to add to the chain. If an instance of that listener is already present
then we stack the new instance instead.
@param index the position in the chain where to insert the listener
@since 10.5RC1