aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-10-02 11:43:19 +0200
committerHenri Sara <henri.sara@gmail.com>2017-10-02 12:43:19 +0300
commit7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce (patch)
tree9351fb5d91124db9935f684da60bdb74ef01881d /server
parent43f4a17f0d17e584e83ea3faaa40ac1def1dd4b1 (diff)
downloadvaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.tar.gz
vaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.zip
Use enhanced for loop for arrays. (#10121)
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/event/EventRouter.java11
-rw-r--r--server/src/main/java/com/vaadin/event/ListenerMethod.java34
-rw-r--r--server/src/main/java/com/vaadin/navigator/Navigator.java4
-rw-r--r--server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java25
-rw-r--r--server/src/main/java/com/vaadin/ui/AbsoluteLayout.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java4
-rw-r--r--server/src/test/java/com/vaadin/tests/server/ClasspathHelper.java4
7 files changed, 37 insertions, 50 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) {
diff --git a/server/src/main/java/com/vaadin/navigator/Navigator.java b/server/src/main/java/com/vaadin/navigator/Navigator.java
index a21cdbcaac..81e141319d 100644
--- a/server/src/main/java/com/vaadin/navigator/Navigator.java
+++ b/server/src/main/java/com/vaadin/navigator/Navigator.java
@@ -992,8 +992,8 @@ public class Navigator implements Serializable {
Map<String, String> parameterMap = new HashMap<>();
String[] parameters = parameterString.split(separator);
- for (int i = 0; i < parameters.length; i++) {
- String[] keyAndValue = parameters[i]
+ for (String parameter : parameters) {
+ String[] keyAndValue = parameter
.split(DEFAULT_STATE_PARAMETER_KEY_VALUE_SEPARATOR);
parameterMap.put(keyAndValue[0],
keyAndValue.length > 1 ? keyAndValue[1] : "");
diff --git a/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java b/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java
index 1f5bbfff29..74f8e1d013 100644
--- a/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java
+++ b/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java
@@ -193,15 +193,14 @@ public class ClassPathExplorer {
if (directory.exists() && !directory.isHidden()) {
// Get the list of the files contained in the directory
- String[] files = directory.list();
- for (int i = 0; i < files.length; i++) {
+ for (String file : directory.list()) {
// we are only interested in .gwt.xml files
- if (!files[i].endsWith(".gwt.xml")) {
+ if (!file.endsWith(".gwt.xml")) {
continue;
}
// remove the .gwt.xml extension
- String classname = files[i].substring(0, files[i].length() - 8);
+ String classname = file.substring(0, file.length() - 8);
String packageName = locationString
.substring(locationString.lastIndexOf('/') + 1);
classname = packageName + "." + classname;
@@ -317,8 +316,7 @@ public class ClassPathExplorer {
debug("Classpath: " + classpath);
String[] split = classpath.split(pathSep);
- for (int i = 0; i < split.length; i++) {
- String classpathEntry = split[i];
+ for (String classpathEntry : split) {
if (acceptClassPathEntry(classpathEntry)) {
locations.add(classpathEntry);
}
@@ -449,21 +447,20 @@ public class ClassPathExplorer {
}
// add all directories recursively
- File[] dirs = file.listFiles(DIRECTORIES_ONLY);
- for (int i = 0; i < dirs.length; i++) {
+ for (File dir : file.listFiles(DIRECTORIES_ONLY)) {
try {
// add the present directory
- if (!dirs[i].isHidden()
- && !dirs[i].getPath().contains(File.separator + ".")) {
- String key = dirs[i].getCanonicalPath() + "/" + name
- + dirs[i].getName();
- URL url = dirs[i].getCanonicalFile().toURI().toURL();
+ if (!dir.isHidden()
+ && !dir.getPath().contains(File.separator + ".")) {
+ String key = dir.getCanonicalPath() + "/" + name
+ + dir.getName();
+ URL url = dir.getCanonicalFile().toURI().toURL();
locations.put(key, url);
}
} catch (Exception ioe) {
return;
}
- include(name + dirs[i].getName(), dirs[i], locations);
+ include(name + dir.getName(), dir, locations);
}
}
diff --git a/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java b/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
index d3f6445bb1..6d0285f0e3 100644
--- a/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
+++ b/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
@@ -302,9 +302,8 @@ public class AbsoluteLayout extends AbstractLayout
return;
}
- String[] cssProperties = css.split(";");
- for (int i = 0; i < cssProperties.length; i++) {
- String[] keyValuePair = cssProperties[i].split(":");
+ for (String cssProperty : css.split(";")) {
+ String[] keyValuePair = cssProperty.split(":");
String key = keyValuePair[0].trim();
if (key.isEmpty()) {
continue;
diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
index 4773fa50e3..e8fa278aba 100644
--- a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
+++ b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
@@ -326,11 +326,11 @@ public class DesignAttributeHandler implements Serializable {
propertyName = removeSubsequentUppercase(propertyName);
String[] words = propertyName.split("(?<!^)(?=[A-Z])");
StringBuilder builder = new StringBuilder();
- for (int i = 0; i < words.length; i++) {
+ for (String word : words) {
if (builder.length() != 0) {
builder.append('-');
}
- builder.append(words[i].toLowerCase());
+ builder.append(word.toLowerCase());
}
return builder.toString();
}
diff --git a/server/src/test/java/com/vaadin/tests/server/ClasspathHelper.java b/server/src/test/java/com/vaadin/tests/server/ClasspathHelper.java
index 946a51a9f1..738f0be806 100644
--- a/server/src/test/java/com/vaadin/tests/server/ClasspathHelper.java
+++ b/server/src/test/java/com/vaadin/tests/server/ClasspathHelper.java
@@ -125,9 +125,7 @@ public class ClasspathHelper {
classpath = classpath.substring(0, classpath.length() - 1);
}
- String[] split = classpath.split(pathSep);
- for (int i = 0; i < split.length; i++) {
- String classpathEntry = split[i];
+ for (String classpathEntry : classpath.split(pathSep)) {
locations.add(classpathEntry);
}