src/share/classes/sun/awt/EventListenerAggregate.java
Print this page
@@ -51,24 +51,19 @@
* @throws NullPointerException if <code>listenerClass</code> is
* <code>null</code>
* @throws ClassCastException if <code>listenerClass</code> is not
* assignable to <code>java.util.EventListener</code>
*/
- public EventListenerAggregate(Class listenerClass) {
+ public EventListenerAggregate(Class<? extends EventListener> listenerClass) {
if (listenerClass == null) {
throw new NullPointerException("listener class is null");
}
- if (!EventListener.class.isAssignableFrom(listenerClass)) {
- throw new ClassCastException("listener class " + listenerClass +
- " is not assignable to EventListener");
- }
-
listenerList = (EventListener[])Array.newInstance(listenerClass, 0);
}
- private Class getListenerClass() {
+ private Class<?> getListenerClass() {
return listenerList.getClass().getComponentType();
}
/**
* Adds the listener to this aggregate.
@@ -78,11 +73,11 @@
* @throws ClassCastException if <code>listener</code> is not
* an instatce of <code>listenerClass</code> specified
* in the constructor
*/
public synchronized void add(EventListener listener) {
- Class listenerClass = getListenerClass();
+ Class<?> listenerClass = getListenerClass();
if (!listenerClass.isInstance(listener)) { // null is not an instance of any class
throw new ClassCastException("listener " + listener + " is not " +
"an instance of listener class " + listenerClass);
}
@@ -105,11 +100,11 @@
* @throws ClassCastException if <code>listener</code> is not
* an instatce of <code>listenerClass</code> specified
* in the constructor
*/
public synchronized boolean remove(EventListener listener) {
- Class listenerClass = getListenerClass();
+ Class<?> listenerClass = getListenerClass();
if (!listenerClass.isInstance(listener)) { // null is not an instance of any class
throw new ClassCastException("listener " + listener + " is not " +
"an instance of listener class " + listenerClass);
}
@@ -153,11 +148,11 @@
*
* @return a copy of all the listeners contained in this aggregate (an empty
* array if there are no listeners)
*/
public synchronized EventListener[] getListenersCopy() {
- return (listenerList.length == 0) ? listenerList : (EventListener[])listenerList.clone();
+ return (listenerList.length == 0) ? listenerList : listenerList.clone();
}
/**
* Returns the number of lisetners in this aggregate.
*