commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r966711 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java
Date Thu, 22 Jul 2010 15:45:50 GMT
Author: mbenson
Date: Thu Jul 22 15:45:49 2010
New Revision: 966711

URL: http://svn.apache.org/viewvc?rev=966711&view=rev
Log:
compiler/generics warnings & a typo

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java?rev=966711&r1=966710&r2=966711&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/event/EventUtils.java
Thu Jul 22 15:45:49 2010
@@ -51,7 +51,7 @@ public class EventUtils
         }
         catch (IllegalAccessException e)
         {
-            throw new IllegalArgumentException("Class " + eventSource.getClass().getName()
+ " does not have an accesible add" + listenerType.getSimpleName () + " method which takes
a parameter of type " + listenerType.getName() + ".");
+            throw new IllegalArgumentException("Class " + eventSource.getClass().getName()
+ " does not have an accessible add" + listenerType.getSimpleName () + " method which takes
a parameter of type " + listenerType.getName() + ".");
         }
         catch (InvocationTargetException e)
         {
@@ -62,6 +62,7 @@ public class EventUtils
     /**
      * Binds an event listener to a specific method on a specific object.
      *
+     * @param <L>
      * @param target       the target object
      * @param methodName   the name of the method to be called
      * @param eventSource  the object which is generating events (JButton, JList, etc.)
@@ -69,9 +70,9 @@ public class EventUtils
      * @param eventTypes   the event types (method names) from the listener interface (if
none specified, all will be
      *                     supported)
      */
-    public static void bindEventsToMethod(Object target, String methodName, Object eventSource,
Class listenerType, String... eventTypes)
+    public static <L> void bindEventsToMethod(Object target, String methodName, Object
eventSource, Class<L> listenerType, String... eventTypes)
     {
-        final Object listener = Proxy.newProxyInstance(target.getClass().getClassLoader(),
new Class[] { listenerType }, new EventBindingInvocationHandler(target, methodName, eventTypes));
+        final L listener = listenerType.cast(Proxy.newProxyInstance(target.getClass().getClassLoader(),
new Class[] { listenerType }, new EventBindingInvocationHandler(target, methodName, eventTypes)));
         addEventListener(eventSource, listenerType, listener);
     }
 



Mime
View raw message