diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-02 11:43:19 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-10-02 12:43:19 +0300 |
commit | 7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce (patch) | |
tree | 9351fb5d91124db9935f684da60bdb74ef01881d /server/src/main/java/com/vaadin/event | |
parent | 43f4a17f0d17e584e83ea3faaa40ac1def1dd4b1 (diff) | |
download | vaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.tar.gz vaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.zip |
Use enhanced for loop for arrays. (#10121)
Diffstat (limited to 'server/src/main/java/com/vaadin/event')
-rw-r--r-- | server/src/main/java/com/vaadin/event/EventRouter.java | 11 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/event/ListenerMethod.java | 34 |
2 files changed, 19 insertions, 26 deletions
diff --git a/server/src/main/java/com/vaadin/event/EventRouter.java b/server/src/main/java/com/vaadin/event/EventRouter.java index f5c04b2de1..59599a0aac 100644 --- a/server/src/main/java/com/vaadin/event/EventRouter.java +++ b/server/src/main/java/com/vaadin/event/EventRouter.java @@ -132,9 +132,9 @@ public class EventRouter implements MethodEventSource { // Find the correct method final Method[] methods = target.getClass().getMethods(); Method method = null; - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals(methodName)) { - method = methods[i]; + for (Method m : methods) { + if (m.getName().equals(methodName)) { + method = m; } } if (method == null) { @@ -197,9 +197,8 @@ public class EventRouter implements MethodEventSource { // Send the event to all listeners. The listeners themselves // will filter out unwanted events. - final Object[] listeners = listenerList.toArray(); - for (int i = 0; i < listeners.length; i++) { - ListenerMethod listenerMethod = (ListenerMethod) listeners[i]; + for (Object l : listenerList.toArray()) { + ListenerMethod listenerMethod = (ListenerMethod) l; if (null != errorHandler) { try { listenerMethod.receiveEvent(event); diff --git a/server/src/main/java/com/vaadin/event/ListenerMethod.java b/server/src/main/java/com/vaadin/event/ListenerMethod.java index c631bbec14..9159f7f781 100644 --- a/server/src/main/java/com/vaadin/event/ListenerMethod.java +++ b/server/src/main/java/com/vaadin/event/ListenerMethod.java @@ -120,9 +120,8 @@ public class ListenerMethod implements EventListener, Serializable { private static Method findHighestMethod(Class<?> cls, String method, Class<?>[] paramTypes) { Class<?>[] ifaces = cls.getInterfaces(); - for (int i = 0; i < ifaces.length; i++) { - Method ifaceMethod = findHighestMethod(ifaces[i], method, - paramTypes); + for (Class<?> c : ifaces) { + Method ifaceMethod = findHighestMethod(c, method, paramTypes); if (ifaceMethod != null) { return ifaceMethod; } @@ -134,11 +133,10 @@ public class ListenerMethod implements EventListener, Serializable { return parentMethod; } } - Method[] methods = cls.getMethods(); - for (int i = 0; i < methods.length; i++) { + for (Method m : cls.getMethods()) { // we ignore parameter types for now - you need to add this - if (methods[i].getName().equals(method)) { - return methods[i]; + if (m.getName().equals(method)) { + return m; } } return null; @@ -245,11 +243,10 @@ public class ListenerMethod implements EventListener, Serializable { throws IllegalArgumentException { // Finds the correct method - final Method[] methods = target.getClass().getMethods(); Method method = null; - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals(methodName)) { - method = methods[i]; + for (Method m : target.getClass().getMethods()) { + if (m.getName().equals(methodName)) { + method = m; } } if (method == null) { @@ -355,11 +352,9 @@ public class ListenerMethod implements EventListener, Serializable { Object[] arguments) throws IllegalArgumentException { // Find the correct method - final Method[] methods = target.getClass().getMethods(); - Method method = null; - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals(methodName)) { - method = methods[i]; + for (Method m : target.getClass().getMethods()) { + if (m.getName().equals(methodName)) { + method = m; } } if (method == null) { @@ -456,11 +451,10 @@ public class ListenerMethod implements EventListener, Serializable { throws IllegalArgumentException { // Finds the correct method - final Method[] methods = target.getClass().getMethods(); Method method = null; - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals(methodName)) { - method = methods[i]; + for (Method m : target.getClass().getMethods()) { + if (m.getName().equals(methodName)) { + method = m; } } if (method == null) { |