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 | |
parent | 43f4a17f0d17e584e83ea3faaa40ac1def1dd4b1 (diff) | |
download | vaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.tar.gz vaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.zip |
Use enhanced for loop for arrays. (#10121)
45 files changed, 197 insertions, 242 deletions
diff --git a/client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java b/client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java index fe69446a7c..aff8e5d268 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java @@ -843,8 +843,7 @@ public final class VDebugWindow extends VOverlay { } }; modes[getDevMode()].setActive(true); - for (int i = 0; i < modes.length; i++) { - Button b = modes[i]; + for (Button b : modes) { b.addClickHandler(modeHandler); mode.add(b); } diff --git a/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java b/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java index d0bf748a93..dbde2df222 100644 --- a/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java +++ b/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java @@ -187,8 +187,8 @@ class ShortcutKeyCombination { modifiersMask = 0; if (modifiers != null) { - for (int i = 0; i < modifiers.length; i++) { - switch (modifiers[i]) { + for (int modifier : modifiers) { + switch (modifier) { case ALT: modifiersMask = modifiersMask | KeyboardListener.MODIFIER_ALT; diff --git a/client/src/main/java/com/vaadin/client/ui/VAbsoluteLayout.java b/client/src/main/java/com/vaadin/client/ui/VAbsoluteLayout.java index d3864d7c03..ec6a5e2496 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbsoluteLayout.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbsoluteLayout.java @@ -430,9 +430,8 @@ public class VAbsoluteLayout extends ComplexPanel { css = position; top = right = bottom = left = zIndex = null; if (!css.isEmpty()) { - String[] properties = css.split(";"); - for (int i = 0; i < properties.length; i++) { - String[] keyValue = properties[i].split(":"); + for (String property : css.split(";")) { + String[] keyValue = property.split(":"); if (keyValue[0].equals("left")) { left = keyValue[1]; } else if (keyValue[0].equals("top")) { diff --git a/client/src/main/java/com/vaadin/client/ui/VContextMenu.java b/client/src/main/java/com/vaadin/client/ui/VContextMenu.java index 2e6f1db697..fec956270e 100644 --- a/client/src/main/java/com/vaadin/client/ui/VContextMenu.java +++ b/client/src/main/java/com/vaadin/client/ui/VContextMenu.java @@ -127,8 +127,7 @@ public class VContextMenu extends VOverlay implements SubPartAware { this.left = left; this.top = top; menu.clearItems(); - for (int i = 0; i < actions.length; i++) { - final Action a = actions[i]; + for (final Action a : actions) { menu.addItem(new MenuItem(a.getHTML(), true, a)); } diff --git a/client/src/main/java/com/vaadin/client/ui/VWindow.java b/client/src/main/java/com/vaadin/client/ui/VWindow.java index 333050c9d9..c39da6d168 100644 --- a/client/src/main/java/com/vaadin/client/ui/VWindow.java +++ b/client/src/main/java/com/vaadin/client/ui/VWindow.java @@ -571,8 +571,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } } }); - for (int i = 0; i < array.length; i++) { - VWindow w = array[i]; + for (VWindow w : array) { if (w.bringToFrontSequence != -1 || w.vaadinModality) { w.bringToFront(false); w.bringToFrontSequence = -1; diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java b/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java index 41b8c6b8e0..40817c5d32 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java @@ -54,8 +54,8 @@ public class VLazyInitItemIdentifiers extends VAcceptCriterion { hashSet = new HashSet<>(); String[] stringArrayAttribute = response .getStringArrayAttribute("allowedIds"); - for (int i = 0; i < stringArrayAttribute.length; i++) { - hashSet.add(stringArrayAttribute[i]); + for (String attribute : stringArrayAttribute) { + hashSet.add(attribute); } loaded = true; if (accepted) { diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java index fc91260783..751f7cb3fe 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java @@ -1702,9 +1702,7 @@ public class VScrollTable extends FlowPanel tHead.removeCell(ROW_HEADER_COLUMN_KEY); } - int i; - for (i = 0; i < strings.length; i++) { - final String cid = strings[i]; + for (final String cid : strings) { visibleColOrder[colIndex] = cid; tHead.enableColumn(cid, colIndex); colIndex++; @@ -1737,9 +1735,7 @@ public class VScrollTable extends FlowPanel tFoot.removeCell(ROW_HEADER_COLUMN_KEY); } - int i; - for (i = 0; i < strings.length; i++) { - final String cid = strings[i]; + for (final String cid : strings) { tFoot.enableColumn(cid, colIndex); colIndex++; } @@ -2118,11 +2114,11 @@ public class VScrollTable extends FlowPanel newIndex--; // columnOrder don't have rowHeader } // add back hidden rows, - for (int i = 0; i < columnOrder.length; i++) { - if (columnOrder[i].equals(oldKeyOnNewIndex)) { + for (String order : columnOrder) { + if (order.equals(oldKeyOnNewIndex)) { break; // break loop at target } - if (isCollapsedColumn(columnOrder[i])) { + if (isCollapsedColumn(order)) { newIndex++; } } @@ -4036,8 +4032,8 @@ public class VScrollTable extends FlowPanel } List<Action> actions = new ArrayList<Action>(cols.length); - for (int i = 0; i < cols.length; i++) { - final String cid = (String) cols[i]; + for (Object col : cols) { + final String cid = (String) col; boolean noncollapsible = noncollapsibleColumns.contains(cid); if (noncollapsible diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayToolbar.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayToolbar.java index 4c745f39c1..b7d31cd7f3 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayToolbar.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayToolbar.java @@ -35,8 +35,8 @@ public class SimpleDayToolbar extends HorizontalPanel { public void setDayNames(String[] dayNames) { clear(); - for (int i = 0; i < dayNames.length; i++) { - Label l = new Label(dayNames[i]); + for (String dayName : dayNames) { + Label l = new Label(dayName); l.setStylePrimaryName("v-calendar-header-day"); add(l); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java index f13a01a5b5..bbe184de86 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java @@ -52,8 +52,9 @@ import com.vaadin.shared.ui.ErrorLevel; * * @author Vaadin Ltd. * @since 3.0 - * @deprecated As of 8.0, replaced by {@link com.vaadin.data.Validator}. The validation is performed - * outside components, see {@link Binder}.{@code withValidator(...)} + * @deprecated As of 8.0, replaced by {@link com.vaadin.data.Validator}. The + * validation is performed outside components, see + * {@link Binder}.{@code withValidator(...)} */ @Deprecated public interface Validator extends Serializable { @@ -140,8 +141,8 @@ public interface Validator extends Serializable { return false; } if (causes != null) { - for (int i = 0; i < causes.length; i++) { - if (!causes[i].isInvisible()) { + for (InvalidValueException e : causes) { + if (!e.isInvisible()) { return false; } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java index ec5138d063..81d91c0d01 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractContainer.java @@ -220,9 +220,8 @@ public abstract class AbstractContainer implements Container { protected void fireContainerPropertySetChange( Container.PropertySetChangeEvent event) { if (getPropertySetChangeListeners() != null) { - final Object[] l = getPropertySetChangeListeners().toArray(); - for (int i = 0; i < l.length; i++) { - ((Container.PropertySetChangeListener) l[i]) + for (Object l : getPropertySetChangeListeners().toArray()) { + ((Container.PropertySetChangeListener) l) .containerPropertySetChange(event); } } @@ -246,9 +245,8 @@ public abstract class AbstractContainer implements Container { */ protected void fireItemSetChange(ItemSetChangeEvent event) { if (getItemSetChangeListeners() != null) { - final Object[] l = getItemSetChangeListeners().toArray(); - for (int i = 0; i < l.length; i++) { - ((Container.ItemSetChangeListener) l[i]) + for (Object l : getItemSetChangeListeners().toArray()) { + ((Container.ItemSetChangeListener) l) .containerItemSetChange(event); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java index 54959822a7..77d837d200 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java @@ -164,11 +164,10 @@ public abstract class AbstractProperty<T> implements Property<T>, */ protected void fireReadOnlyStatusChange() { if (readOnlyStatusChangeListeners != null) { - final Object[] l = readOnlyStatusChangeListeners.toArray(); final Property.ReadOnlyStatusChangeEvent event = new ReadOnlyStatusChangeEvent( this); - for (int i = 0; i < l.length; i++) { - ((Property.ReadOnlyStatusChangeListener) l[i]) + for (Object l : readOnlyStatusChangeListeners.toArray()) { + ((Property.ReadOnlyStatusChangeListener) l) .readOnlyStatusChange(event); } } @@ -245,10 +244,9 @@ public abstract class AbstractProperty<T> implements Property<T>, */ protected void fireValueChange() { if (valueChangeListeners != null) { - final Object[] l = valueChangeListeners.toArray(); final Property.ValueChangeEvent event = new ValueChangeEvent(this); - for (int i = 0; i < l.length; i++) { - ((Property.ValueChangeListener) l[i]).valueChange(event); + for (Object l : valueChangeListeners.toArray()) { + ((Property.ValueChangeListener) l).valueChange(event); } } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java index e9f160dedd..de605a9ed6 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java @@ -184,8 +184,8 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, Object[] array = roots.toArray(); Arrays.sort(array, basedOnOrderFromWrappedContainer); roots = new LinkedHashSet<Object>(); - for (int i = 0; i < array.length; i++) { - roots.add(array[i]); + for (Object root : array) { + roots.add(root); } for (Object object : children.keySet()) { LinkedList<Object> object2 = children.get(object); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java index 9fca1061fd..4ae90a7569 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java @@ -278,8 +278,8 @@ public class FilesystemContainer implements Container.Hierarchical { if (!(itemId instanceof File)) { return false; } - for (int i = 0; i < roots.length; i++) { - if (roots[i].equals(itemId)) { + for (File root : roots) { + if (root.equals(itemId)) { return true; } } @@ -374,10 +374,10 @@ public class FilesystemContainer implements Container.Hierarchical { boolean val = false; // Try to match all roots - for (int i = 0; i < roots.length; i++) { + for (File root : roots) { try { val |= ((File) itemId).getCanonicalPath() - .startsWith(roots[i].getCanonicalPath()); + .startsWith(root.getCanonicalPath()); } catch (final IOException e) { // Exception ignored } @@ -444,8 +444,8 @@ public class FilesystemContainer implements Container.Hierarchical { if (recursive) { final Collection<File> col = new ArrayList<File>(); - for (int i = 0; i < roots.length; i++) { - addItemIds(col, roots[i]); + for (File root : roots) { + addItemIds(col, root); } return Collections.unmodifiableCollection(col); } else { @@ -554,24 +554,24 @@ public class FilesystemContainer implements Container.Hierarchical { * Internal method to recursively calculate the number of files under a root * directory. * - * @param f + * @param directory * the root to start counting from. */ - private int getFileCounts(File f) { + private int getFileCounts(File directory) { File[] l; if (filter != null) { - l = f.listFiles(filter); + l = directory.listFiles(filter); } else { - l = f.listFiles(); + l = directory.listFiles(); } if (l == null) { return 0; } int ret = l.length; - for (int i = 0; i < l.length; i++) { - if (l[i].isDirectory()) { - ret += getFileCounts(l[i]); + for (File f : l) { + if (f.isDirectory()) { + ret += getFileCounts(f); } } return ret; @@ -588,8 +588,8 @@ public class FilesystemContainer implements Container.Hierarchical { if (recursive) { int counts = 0; - for (int i = 0; i < roots.length; i++) { - counts += getFileCounts(roots[i]); + for (File f : roots) { + counts += getFileCounts(f); } return counts; } else { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java index aa504409db..da6ff62b92 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java @@ -615,10 +615,9 @@ public class HierarchicalContainer extends IndexedContainer boolean success = true; Collection<?> children2 = container.getChildren(itemId); if (children2 != null) { - Object[] array = children2.toArray(); - for (int i = 0; i < array.length; i++) { + for (Object o : children2.toArray()) { boolean removeItemRecursively = removeItemRecursively(container, - array[i]); + o); if (!removeItemRecursively) { success = false; } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java index bd74a132b0..98f2deecac 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java @@ -526,11 +526,10 @@ public class IndexedContainer // Sends event to listeners listening all value changes if (propertyValueChangeListeners != null) { - final Object[] l = propertyValueChangeListeners.toArray(); final Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent( source); - for (int i = 0; i < l.length; i++) { - ((Property.ValueChangeListener) l[i]).valueChange(event); + for (Object l : propertyValueChangeListeners.toArray()) { + ((Property.ValueChangeListener) l).valueChange(event); } } @@ -544,9 +543,8 @@ public class IndexedContainer if (listenerList != null) { final Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent( source); - Object[] listeners = listenerList.toArray(); - for (int i = 0; i < listeners.length; i++) { - ((Property.ValueChangeListener) listeners[i]) + for (Object listener : listenerList.toArray()) { + ((Property.ValueChangeListener) listener) .valueChange(event); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java index f2fab292af..8b44785e93 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java @@ -351,26 +351,26 @@ public class MethodProperty<T> extends AbstractProperty<T> { this.type = type; // Find set and get -methods - final Method[] m = instance.getClass().getMethods(); + final Method[] methods = instance.getClass().getMethods(); // Finds get method boolean found = false; - for (int i = 0; i < m.length; i++) { + for (Method m : methods) { // Tests the name of the get Method - if (!m[i].getName().equals(getMethodName)) { + if (!m.getName().equals(getMethodName)) { // name does not match, try next method continue; } // Tests return type - if (!type.equals(m[i].getReturnType())) { + if (!type.equals(m.getReturnType())) { continue; } // Tests the parameter types - final Class<?>[] c = m[i].getParameterTypes(); + final Class<?>[] c = m.getParameterTypes(); if (c.length != getArgs.length) { // not the right amount of parameters, try next method @@ -395,7 +395,7 @@ public class MethodProperty<T> extends AbstractProperty<T> { + "-method"); } else { found = true; - getMethod = m[i]; + getMethod = m; } } } @@ -409,17 +409,17 @@ public class MethodProperty<T> extends AbstractProperty<T> { // Finds setMethod found = false; - for (int i = 0; i < m.length; i++) { + for (Method m : methods) { // Checks name - if (!m[i].getName().equals(setMethodName)) { + if (!m.getName().equals(setMethodName)) { // name does not match, try next method continue; } // Checks parameter compatibility - final Class<?>[] c = m[i].getParameterTypes(); + final Class<?>[] c = m.getParameterTypes(); if (c.length != setArgs.length) { // not the right amount of parameters, try next method @@ -448,7 +448,7 @@ public class MethodProperty<T> extends AbstractProperty<T> { + "-method"); } else { found = true; - setMethod = m[i]; + setMethod = m; } } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java index 48052a7671..4228f04dcb 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java @@ -144,8 +144,8 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> { throw new IllegalArgumentException( "Invalid property name '" + propertyName + "'"); } - for (int i = 0; i < simplePropertyNames.length; i++) { - String simplePropertyName = simplePropertyNames[i].trim(); + for (String simplePropertyName : simplePropertyNames) { + simplePropertyName = simplePropertyName.trim(); if (!simplePropertyName.isEmpty()) { lastSimplePropertyName = simplePropertyName; lastClass = propertyClass; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java index 81eb4eb00d..d7be9c54e8 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java @@ -259,11 +259,10 @@ public class PropertysetItem */ private void fireItemPropertySetChange() { if (propertySetChangeListeners != null) { - final Object[] l = propertySetChangeListeners.toArray(); final Item.PropertySetChangeEvent event = new PropertysetItem.PropertySetChangeEvent( this); - for (int i = 0; i < l.length; i++) { - ((Item.PropertySetChangeListener) l[i]) + for (Object l : propertySetChangeListeners.toArray()) { + ((Item.PropertySetChangeListener) l) .itemPropertySetChange(event); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java index 7591ca7a75..e8c6f99c90 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java @@ -1460,11 +1460,10 @@ public class SQLContainer implements Container, Container.Filterable, protected void fireContentsChange() { if (itemSetChangeListeners != null) { - final Object[] l = itemSetChangeListeners.toArray(); final Container.ItemSetChangeEvent event = new SQLContainer.ItemSetChangeEvent( this); - for (int i = 0; i < l.length; i++) { - ((Container.ItemSetChangeListener) l[i]) + for (Object l : itemSetChangeListeners.toArray()) { + ((Container.ItemSetChangeListener) l) .containerItemSetChange(event); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java index 620a29f83a..f23326e4f3 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java @@ -479,9 +479,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements // Converts the key-array to id-set final LinkedList<Object> acceptedSelections = new LinkedList<Object>(); - for (int i = 0; i < clientSideSelectedKeys.length; i++) { - final Object id = itemIdMapper - .get(clientSideSelectedKeys[i]); + for (String key : clientSideSelectedKeys) { + final Object id = itemIdMapper.get(key); if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed @@ -1721,9 +1720,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements && !propertySetEventListeners.isEmpty()) { final Container.PropertySetChangeEvent event = new PropertySetChangeEvent( this); - final Object[] listeners = propertySetEventListeners.toArray(); - for (int i = 0; i < listeners.length; i++) { - ((Container.PropertySetChangeListener) listeners[i]) + for (Object l : propertySetEventListeners.toArray()) { + ((Container.PropertySetChangeListener) l) .containerPropertySetChange(event); } } @@ -1737,9 +1735,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) { final Container.ItemSetChangeEvent event = new ItemSetChangeEvent( this); - final Object[] listeners = itemSetEventListeners.toArray(); - for (int i = 0; i < listeners.length; i++) { - ((Container.ItemSetChangeListener) listeners[i]) + for (Object l : itemSetEventListeners.toArray()) { + ((Container.ItemSetChangeListener) l) .containerItemSetChange(event); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java index 3c717ac954..52f36e9906 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java @@ -695,20 +695,19 @@ public class Table extends AbstractSelect implements Action.Container, // Checks that the new visible columns contains no nulls, properties // exist and that there are no duplicates before adding them to newVC. final Collection<?> properties = getContainerPropertyIds(); - for (int i = 0; i < visibleColumns.length; i++) { - if (visibleColumns[i] == null) { + for (Object id : visibleColumns) { + if (id == null) { throw new NullPointerException("Ids must be non-nulls"); - } else if (!properties.contains(visibleColumns[i]) - && !columnGenerators.containsKey(visibleColumns[i])) { + } else if (!properties.contains(id) + && !columnGenerators.containsKey(id)) { throw new IllegalArgumentException( "Ids must exist in the Container or as a generated column, missing id: " - + visibleColumns[i]); - } else if (newVC.contains(visibleColumns[i])) { + + id); + } else if (newVC.contains(id)) { throw new IllegalArgumentException( - "Ids must be unique, duplicate id: " - + visibleColumns[i]); + "Ids must be unique, duplicate id: " + id); } else { - newVC.add(visibleColumns[i]); + newVC.add(id); } } @@ -1476,11 +1475,10 @@ public class Table extends AbstractSelect implements Action.Container, return; } final LinkedList<Object> newOrder = new LinkedList<Object>(); - for (int i = 0; i < columnOrder.length; i++) { - if (columnOrder[i] != null - && visibleColumns.contains(columnOrder[i])) { - visibleColumns.remove(columnOrder[i]); - newOrder.add(columnOrder[i]); + for (Object id : columnOrder) { + if (id != null && visibleColumns.contains(id)) { + visibleColumns.remove(id); + newOrder.add(id); } } for (final Object columnId : visibleColumns) { @@ -2848,9 +2846,9 @@ public class Table extends AbstractSelect implements Action.Container, * selected on the client side (the ones that the client side is aware * of). */ - for (int i = 0; i < ka.length; i++) { + for (String k : ka) { // key to id - final Object id = itemIdMapper.get(ka[i]); + final Object id = itemIdMapper.get(k); if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed @@ -2892,8 +2890,8 @@ public class Table extends AbstractSelect implements Action.Container, private Set<Object> getCurrentlyRenderedItemIds() { HashSet<Object> ids = new HashSet<Object>(); if (pageBuffer != null) { - for (int i = 0; i < pageBuffer[CELL_ITEMID].length; i++) { - ids.add(pageBuffer[CELL_ITEMID][i]); + for (Object id : pageBuffer[CELL_ITEMID]) { + ids.add(id); } } return ids; @@ -4486,8 +4484,8 @@ public class Table extends AbstractSelect implements Action.Container, // may be null if the table has not been rendered yet (e.g. not attached // to a layout) if (null != cells) { - for (int i = 0; i < cells[CELL_ITEMID].length; i++) { - visible.add(cells[CELL_ITEMID][i]); + for (Object id : cells[CELL_ITEMID]) { + visible.add(id); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java index 2d6c1e521e..7738c166f7 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java @@ -529,9 +529,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Collapses the nodes if (variables.containsKey("collapse")) { - final String[] keys = (String[]) variables.get("collapse"); - for (int i = 0; i < keys.length; i++) { - final Object id = itemIdMapper.get(keys[i]); + for (String key : (String[]) variables.get("collapse")) { + final Object id = itemIdMapper.get(key); if (id != null && isExpanded(id)) { expanded.remove(id); if (expandedItemId == id) { @@ -548,9 +547,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (variables.containsKey("requestChildTree")) { sendChildTree = true; } - final String[] keys = (String[]) variables.get("expand"); - for (int i = 0; i < keys.length; i++) { - final Object id = itemIdMapper.get(keys[i]); + for (String key : (String[]) variables.get("expand")) { + final Object id = itemIdMapper.get(key); if (id != null) { expandItem(id, sendChildTree); } @@ -593,12 +591,11 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * The variables sent to the server from the client */ private void handleSelectedItems(Map<String, Object> variables) { - final String[] ka = (String[]) variables.get("selected"); // Converts the key-array to id-set final LinkedList<Object> s = new LinkedList<Object>(); - for (int i = 0; i < ka.length; i++) { - final Object id = itemIdMapper.get(ka[i]); + for (String key : (String[]) variables.get("selected")) { + final Object id = itemIdMapper.get(key); if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed 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); } diff --git a/shared/src/main/java/com/vaadin/shared/util/SharedUtil.java b/shared/src/main/java/com/vaadin/shared/util/SharedUtil.java index 2cab2fd5b5..9a837c1e75 100644 --- a/shared/src/main/java/com/vaadin/shared/util/SharedUtil.java +++ b/shared/src/main/java/com/vaadin/shared/util/SharedUtil.java @@ -164,8 +164,8 @@ public class SharedUtil implements Serializable { return ""; } StringBuilder sb = new StringBuilder(); - for (int i = 0; i < parts.length; i++) { - sb.append(parts[i]); + for (String part : parts) { + sb.append(part); sb.append(separator); } return sb.substring(0, sb.length() - separator.length()); diff --git a/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java index 93ddea656f..7599522c38 100644 --- a/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java +++ b/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java @@ -371,11 +371,11 @@ public class DevelopmentServerLauncher { */ protected static Map<String, String> parseArguments(String[] args) { final Map<String, String> map = new HashMap<>(); - for (int i = 0; i < args.length; i++) { - final int d = args[i].indexOf("="); - if (d > 0 && d < args[i].length() && args[i].startsWith("--")) { - final String name = args[i].substring(2, d); - final String value = args[i].substring(d + 1); + for (String arg : args) { + final int d = arg.indexOf("="); + if (d > 0 && d < arg.length() && arg.startsWith("--")) { + final String name = arg.substring(2, d); + final String value = arg.substring(d + 1); map.put(name, value); } } diff --git a/uitest/src/main/java/com/vaadin/tests/TestBench.java b/uitest/src/main/java/com/vaadin/tests/TestBench.java index 2c5634ab32..56c5dc986a 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestBench.java +++ b/uitest/src/main/java/com/vaadin/tests/TestBench.java @@ -307,9 +307,8 @@ public class TestBench extends com.vaadin.server.LegacyApplication } } - // for (int i = 0; i < c.getInterfaces().length; i++) { - // Class cc = c.getInterfaces()[i]; - // if (c.getInterfaces()[i].equals(Testable.class)) { + // for (Class cc : c.getInterfaces()) { + // if (cc.equals(Testable.class)) { // // Class is testable // classes.add(c); // } diff --git a/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java b/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java index 74dcd40ba1..971d0d9bfd 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java @@ -82,11 +82,10 @@ public class TestForMultipleStyleNames extends CustomComponent public void valueChange(ValueChangeEvent event) { final String currentStyle = l.getStyleName(); - final String[] tmp = currentStyle.split(" "); final List<String> curStyles = new ArrayList<>(); - for (int i = 0; i < tmp.length; i++) { - if (tmp[i] != "") { - curStyles.add(tmp[i]); + for (String tmp : currentStyle.split(" ")) { + if (tmp != "") { + curStyles.add(tmp); } } diff --git a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java index 45de6b34a4..95602fb78b 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java +++ b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java @@ -144,8 +144,7 @@ public class TestSizeableIncomponents extends LegacyApplication { URL dir = cl.getResource("com/vaadin/ui"); String[] list2 = (new File(dir.getFile())).list(); - for (int i = 0; i < list2.length; i++) { - String f = list2[i]; + for (String f : list2) { if (f.endsWith(".class") && (f.indexOf("CustomComponent") == -1) && (f.indexOf("Window") == -1)) { f = f.replaceAll(".class", ""); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java index c665537250..bbc067ec39 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java @@ -9,16 +9,16 @@ import com.vaadin.v7.shared.ui.combobox.FilteringMode; import com.vaadin.v7.ui.ComboBox; public class ComboBoxCombinedWithEnterShortcut extends TestBase { - final String[] cities = { "Berlin", "Brussels", "Helsinki", - "Madrid", "Oslo", "Paris", "Stockholm" }; + final String[] cities = { "Berlin", "Brussels", "Helsinki", "Madrid", + "Oslo", "Paris", "Stockholm" }; private Log log = new Log(5); @Override protected void setup() { final ComboBox l = new ComboBox("Please select a city"); - for (int i = 0; i < cities.length; i++) { - l.addItem(cities[i]); + for (String city : cities) { + l.addItem(city); } l.setFilteringMode(FilteringMode.OFF); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java index af894cf61e..d88e2ce286 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java @@ -85,8 +85,8 @@ public class HeaderPositionWhenSorting extends AbstractReindeerTestUI // Calculate the average of the numeric column double avgAge = 0; - for (int i = 0; i < people.length; i++) { - avgAge += (Integer) people[i][1]; + for (Object[] person : people) { + avgAge += (Integer) person[1]; } avgAge /= people.length; @@ -98,8 +98,7 @@ public class HeaderPositionWhenSorting extends AbstractReindeerTestUI // Adjust the table height a bit table.setPageLength(table.size() + 2); - for (int i = 0; i < people.length; i++) { - Object[] person = people[i]; + for (Object[] person : people) { String name = (String) person[0]; addComponent(new Link("Google for " + name, new ExternalResource( "http://www.google.co.uk/search?q=" + name))); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java index 89b4b46da4..64bf1c908c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java @@ -83,8 +83,8 @@ public class TableAndBrowserContextMenu extends TestBase // Calculate the average of the numeric column double avgAge = 0; - for (int i = 0; i < people.length; i++) { - avgAge += (Integer) people[i][1]; + for (Object[] person : people) { + avgAge += (Integer) person[1]; } avgAge /= people.length; @@ -96,8 +96,7 @@ public class TableAndBrowserContextMenu extends TestBase // Adjust the table height a bit table.setPageLength(table.size() + 2); - for (int i = 0; i < people.length; i++) { - Object[] person = people[i]; + for (Object[] person : people) { String name = (String) person[0]; addComponent(new Link("Google for " + name, new ExternalResource( "http://www.google.co.uk/search?q=" + name))); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java index 815ebc5197..441d2a4302 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java @@ -69,9 +69,9 @@ public class TextChangeEvents extends AbstractTestUIWithLog { */ private class VaadinDeveloperNameField extends TextField implements HasValue.ValueChangeListener<String> { - private String[] names = { "Matti Tahvonen", - "Marc Englund", "Joonas Lehtinen", "Jouni Koivuviita", - "Marko Grönroos", "Artur Signell" }; + private String[] names = { "Matti Tahvonen", "Marc Englund", + "Joonas Lehtinen", "Jouni Koivuviita", "Marko Grönroos", + "Artur Signell" }; public VaadinDeveloperNameField() { setCaption("Start typing 'old' Vaadin developers."); @@ -111,9 +111,9 @@ public class TextChangeEvents extends AbstractTestUIWithLog { private String findMatch(String currentTextContent) { if (!currentTextContent.isEmpty()) { - for (int i = 0; i < names.length; i++) { - if (names[i].startsWith(currentTextContent)) { - return names[i]; + for (String name : names) { + if (name.startsWith(currentTextContent)) { + return name; } } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java index 5c98476630..71b0a801b6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java @@ -100,9 +100,9 @@ public class TextFieldsValueChangeMode extends AbstractTestUIWithLog { * */ private class VaadinDeveloperNameField extends TextField { - private String[] names = { "Matti Tahvonen", - "Marc Englund", "Joonas Lehtinen", "Jouni Koivuviita", - "Marko Grönroos", "Artur Signell" }; + private String[] names = { "Matti Tahvonen", "Marc Englund", + "Joonas Lehtinen", "Jouni Koivuviita", "Marko Grönroos", + "Artur Signell" }; public VaadinDeveloperNameField() { setCaption("Start typing 'old' Vaadin developers."); @@ -139,9 +139,9 @@ public class TextFieldsValueChangeMode extends AbstractTestUIWithLog { private String findMatch(String currentTextContent) { if (!currentTextContent.isEmpty()) { - for (int i = 0; i < names.length; i++) { - if (names[i].startsWith(currentTextContent)) { - return names[i]; + for (String name : names) { + if (name.startsWith(currentTextContent)) { + return name; } } } diff --git a/uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java b/uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java index 384a02b87b..d525c4f9e8 100644 --- a/uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java +++ b/uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java @@ -47,8 +47,7 @@ public class DragAndDropFiles extends TestBase { Html5File[] files = transferable.getFiles(); if (files != null) { - for (int i = 0; i < files.length; i++) { - Html5File file = files[i]; + for (Html5File file : files) { // Max 1 MB files are uploaded if (file.getFileSize() > 1024 * 1024) { getMainWindow().showNotification("File " diff --git a/uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java b/uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java index 768177683a..6a415f4268 100644 --- a/uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java +++ b/uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java @@ -31,9 +31,9 @@ public class CompatibilityAbstractFieldElementSetValueReadOnly @Override protected void setup(VaadinRequest request) { - for (int i = 0; i < elems.length; i++) { - elems[i].setReadOnly(true); - addComponent(elems[i]); + for (AbstractField<?> c : elems) { + c.setReadOnly(true); + addComponent(c); } } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java b/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java index 1e7b310c53..76bdb6cd13 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java @@ -112,21 +112,20 @@ public class ButtonsTest extends com.vaadin.server.LegacyApplication { private Layout buildButtons(boolean disabled, boolean icon, boolean error, boolean sized) { - String[] buttonStyles = { "Normal", "Primary", "Small", - "Link" }; + String[] buttonStyles = { "Normal", "Primary", "Small", "Link" }; HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setMargin(true); - for (int i = 0; i < buttonStyles.length; i++) { + for (String style : buttonStyles) { Button b; if (nativeButtons) { - b = new NativeButton(buttonStyles[i] + " style"); + b = new NativeButton(style + " style"); } else { - b = new Button(buttonStyles[i] + " style"); + b = new Button(style + " style"); } - b.setStyleName(buttonStyles[i].toLowerCase()); + b.setStyleName(style.toLowerCase()); if (icon) { b.setIcon(new ThemeResource("../runo/icons/" + (largeIcons ? "64" : "16") + "/document.png")); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java b/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java index 207d62d157..cc8ee57dd0 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java @@ -81,9 +81,9 @@ public class TextChangeEvents extends TestBase { */ private class VaadinDeveloperNameField extends TextField implements TextChangeListener { - private String[] names = { "Matti Tahvonen", - "Marc Englund", "Joonas Lehtinen", "Jouni Koivuviita", - "Marko Grönroos", "Artur Signell" }; + private String[] names = { "Matti Tahvonen", "Marc Englund", + "Joonas Lehtinen", "Jouni Koivuviita", "Marko Grönroos", + "Artur Signell" }; public VaadinDeveloperNameField() { setCaption("Start typing 'old' Vaadin developers."); @@ -123,9 +123,9 @@ public class TextChangeEvents extends TestBase { private String findMatch(String currentTextContent) { if (!currentTextContent.isEmpty()) { - for (int i = 0; i < names.length; i++) { - if (names[i].startsWith(currentTextContent)) { - return names[i]; + for (String name : names) { + if (name.startsWith(currentTextContent)) { + return name; } } } diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java index 934c25f330..c2c4e7d262 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java @@ -13,7 +13,7 @@ import com.vaadin.v7.ui.AbstractSelect.ItemDescriptionGenerator; import com.vaadin.v7.ui.Tree; public class SimpleTree extends TestBase implements Action.Handler { - private static final String[][] hardware = { // + private static final String[][] hardware = { { "Desktops", "Dell OptiPlex GX240", "Dell OptiPlex GX260", "Dell OptiPlex GX280" }, { "Monitors", "Benq T190HD", "Benq T220HD", "Benq T240HD" }, @@ -28,8 +28,7 @@ public class SimpleTree extends TestBase implements Action.Handler { // Actions for the context menu private static final Action ACTION_ADD = new Action("Add child item"); private static final Action ACTION_DELETE = new Action("Delete"); - private static final Action[] ACTIONS = { ACTION_ADD, - ACTION_DELETE }; + private static final Action[] ACTIONS = { ACTION_ADD, ACTION_DELETE }; private Tree tree; @@ -83,15 +82,15 @@ public class SimpleTree extends TestBase implements Action.Handler { // Create containerproperty for icon hwContainer.addContainerProperty("icon", ThemeResource.class, new ThemeResource("../runo/icons/16/document.png")); - for (int i = 0; i < hardware.length; i++) { + for (String[] type : hardware) { // Add new item item = hwContainer.addItem(itemId); // Add name property for item - item.getItemProperty("name").setValue(hardware[i][0]); + item.getItemProperty("name").setValue(type[0]); // Allow children hwContainer.setChildrenAllowed(itemId, true); itemId++; - for (int j = 1; j < hardware[i].length; j++) { + for (int j = 1; j < type.length; j++) { if (j == 1) { item.getItemProperty("icon").setValue( new ThemeResource("../runo/icons/16/folder.png")); @@ -99,7 +98,7 @@ public class SimpleTree extends TestBase implements Action.Handler { // Add child items item = hwContainer.addItem(itemId); - item.getItemProperty("name").setValue(hardware[i][j]); + item.getItemProperty("name").setValue(type[j]); hwContainer.setParent(itemId, itemId - j); hwContainer.setChildrenAllowed(itemId, false); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java index b38e4d9bf3..a2d4aa1c80 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java @@ -60,22 +60,22 @@ public class TreeHorizontalResize extends TestBase { // Create containerproperty for icon hwContainer.addContainerProperty(hw_PROPERTY_ICON, ThemeResource.class, new ThemeResource("../runo/icons/16/document.png")); - for (int i = 0; i < hardware.length; i++) { + for (String[] type : hardware) { // Add new item item = hwContainer.addItem(itemId); // Add name property for item - item.getItemProperty(hw_PROPERTY_NAME).setValue(hardware[i][0]); + item.getItemProperty(hw_PROPERTY_NAME).setValue(type[0]); // Allow children hwContainer.setChildrenAllowed(itemId, true); itemId++; - for (int j = 1; j < hardware[i].length; j++) { + for (int j = 1; j < type.length; j++) { if (j == 1) { item.getItemProperty(hw_PROPERTY_ICON).setValue( new ThemeResource("../runo/icons/16/folder.png")); } // Add child items item = hwContainer.addItem(itemId); - item.getItemProperty(hw_PROPERTY_NAME).setValue(hardware[i][j]); + item.getItemProperty(hw_PROPERTY_NAME).setValue(type[j]); hwContainer.setParent(itemId, itemId - j); hwContainer.setChildrenAllowed(itemId, false); |