jdk/src/share/classes/java/beans/ChangeListenerMap.java
author mcimadamore
Thu, 01 Dec 2011 18:34:23 +0000
changeset 11120 f8576c769572
parent 5506 202f599c92aa
child 12032 49ac5a2b1d5c
permissions -rw-r--r--
7116954: Misc warnings in java.beans/java.beans.context Summary: Remove generic warnings form java.beans and java.beans.context Reviewed-by: alanb, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.beans;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.EventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.EventListenerProxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Map.Entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This is an abstract class that provides base functionality
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * for the {@link PropertyChangeSupport PropertyChangeSupport} class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * and the {@link VetoableChangeSupport VetoableChangeSupport} class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @see PropertyChangeListenerMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see VetoableChangeListenerMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author Sergey A. Malenkov
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
abstract class ChangeListenerMap<L extends EventListener> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private Map<String, L[]> map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * Creates an array of listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * This method can be optimized by using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * the same instance of the empty array
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * when {@code length} is equal to {@code 0}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * @param length  the array length
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @return        an array with specified length
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    protected abstract L[] newArray(int length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Creates a proxy listener for the specified property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param name      the name of the property to listen on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param listener  the listener to process events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @return          a proxy listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    protected abstract L newProxy(String name, L listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Adds a listener to the list of listeners for the specified property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * This listener is called as many times as it was added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param name      the name of the property to listen on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param listener  the listener to process events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public final synchronized void add(String name, L listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        if (this.map == null) {
11120
f8576c769572 7116954: Misc warnings in java.beans/java.beans.context
mcimadamore
parents: 5506
diff changeset
    79
            this.map = new HashMap<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        L[] array = this.map.get(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        int size = (array != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                ? array.length
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        L[] clone = newArray(size + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        clone[size] = listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        if (array != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            System.arraycopy(array, 0, clone, 0, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        this.map.put(name, clone);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Removes a listener from the list of listeners for the specified property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * If the listener was added more than once to the same event source,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * this listener will be notified one less time after being removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param name      the name of the property to listen on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param listener  the listener to process events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public final synchronized void remove(String name, L listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (this.map != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            L[] array = this.map.get(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            if (array != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                for (int i = 0; i < array.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                    if (listener.equals(array[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                        int size = array.length - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                        if (size > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                            L[] clone = newArray(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                            System.arraycopy(array, 0, clone, 0, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                            System.arraycopy(array, i + 1, clone, i, size - i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                            this.map.put(name, clone);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                            this.map.remove(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                            if (this.map.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                this.map = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Returns the list of listeners for the specified property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param name  the name of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @return      the corresponding list of listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public final synchronized L[] get(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        return (this.map != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                ? this.map.get(name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Sets new list of listeners for the specified property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @param name       the name of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param listeners  new list of listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public final void set(String name, L[] listeners) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (listeners != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            if (this.map == null) {
11120
f8576c769572 7116954: Misc warnings in java.beans/java.beans.context
mcimadamore
parents: 5506
diff changeset
   149
                this.map = new HashMap<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            this.map.put(name, listeners);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        else if (this.map != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            this.map.remove(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            if (this.map.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                this.map = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Returns all listeners in the map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @return an array of all listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public final synchronized L[] getListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        if (this.map == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            return newArray(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
11120
f8576c769572 7116954: Misc warnings in java.beans/java.beans.context
mcimadamore
parents: 5506
diff changeset
   170
        List<L> list = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        L[] listeners = this.map.get(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if (listeners != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            for (L listener : listeners) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                list.add(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        for (Entry<String, L[]> entry : this.map.entrySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            String name = entry.getKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            if (name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                for (L listener : entry.getValue()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    list.add(newProxy(name, listener));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return list.toArray(newArray(list.size()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * Returns listeners that have been associated with the named property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @param name  the name of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @return an array of listeners for the named property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public final L[] getListeners(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            L[] listeners = get(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            if (listeners != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                return listeners.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return newArray(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * Indicates whether the map contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * at least one listener to be notified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @param name  the name of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @return      {@code true} if at least one listener exists or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *              {@code false} otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public final synchronized boolean hasListeners(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (this.map == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        L[] array = this.map.get(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return (array != null) || ((name != null) && (null != this.map.get(name)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Returns a set of entries from the map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Each entry is a pair consisted of the property name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * and the corresponding list of listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @return a set of entries from the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public final Set<Entry<String, L[]>> getEntries() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        return (this.map != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                ? this.map.entrySet()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                : Collections.<Entry<String, L[]>>emptySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * Extracts a real listener from the proxy listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * It is necessary because default proxy class is not serializable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @return a real listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public final L extract(L listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        while (listener instanceof EventListenerProxy) {
11120
f8576c769572 7116954: Misc warnings in java.beans/java.beans.context
mcimadamore
parents: 5506
diff changeset
   242
            @SuppressWarnings("unchecked")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            EventListenerProxy<L> proxy = (EventListenerProxy<L>) listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            listener = proxy.getListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return listener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
}