aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-09-29 14:14:05 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-09-29 15:14:05 +0300
commitadcf2e2e80c6a05ea5e43be15dc7a2576fd2bbb4 (patch)
tree0a58b0b09cb371f757d74f83ad872f2113f96272
parent46950473fdb3cfb9d44660b3a642a9229cecded2 (diff)
downloadvaadin-framework-adcf2e2e80c6a05ea5e43be15dc7a2576fd2bbb4.tar.gz
vaadin-framework-adcf2e2e80c6a05ea5e43be15dc7a2576fd2bbb4.zip
Use enhanced for loop instead of Iterator. (#10100)
-rw-r--r--client/src/main/java/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java14
-rw-r--r--client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java11
-rw-r--r--client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java11
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java15
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VComboBox.java5
-rw-r--r--client/src/main/java/com/vaadin/client/widgets/ChildFocusAwareFlowPanel.java10
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java12
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java5
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java13
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java58
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java10
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java11
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DayToolbar.java7
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java8
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java6
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java12
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerHierarchicalWrapper.java7
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerOrderedWrapper.java7
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java4
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/ListSet.java9
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java14
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java10
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java13
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java9
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java70
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java9
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java65
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java6
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java5
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerHistory.java11
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java12
-rw-r--r--compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java6
-rw-r--r--compatibility-server/src/test/java/com/vaadin/v7/data/util/ContainerSortingTest.java5
-rw-r--r--server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java5
-rw-r--r--server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/ConnectorTracker.java7
-rw-r--r--server/src/main/java/com/vaadin/ui/GridLayout.java6
-rw-r--r--server/src/main/java/com/vaadin/ui/MenuBar.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java7
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java7
-rw-r--r--server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java7
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java5
-rw-r--r--server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java12
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestBench.java19
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/accordion/RemoveTabs.java11
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/composite/CompositeChainUI.java7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java11
-rw-r--r--uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java6
49 files changed, 212 insertions, 395 deletions
diff --git a/client/src/main/java/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/main/java/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java
index 76360eb40d..d2c818f2f5 100644
--- a/client/src/main/java/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java
+++ b/client/src/main/java/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java
@@ -16,7 +16,6 @@
package com.vaadin.client.componentlocator;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import com.google.gwt.core.client.JavaScriptObject;
@@ -470,10 +469,8 @@ public class LegacyLocatorStrategy implements LocatorStrategy {
return null;
}
- Iterator<?> i = ((Iterable<?>) parent).iterator();
int pos = 0;
- while (i.hasNext()) {
- Object child = i.next();
+ for (Object child : (Iterable<?>) parent) {
if (child == w) {
return basePath + PARENTCHILD_SEPARATOR + simpleName + "[" + pos
+ "]";
@@ -638,7 +635,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy {
}
// Locate the child
- Iterator<? extends Widget> iterator;
+ Iterable<? extends Widget> iterable;
/*
* VWindow and VContextMenu workarounds for backwards
@@ -652,19 +649,18 @@ public class LegacyLocatorStrategy implements LocatorStrategy {
for (WindowConnector wc : windows) {
windowWidgets.add(wc.getWidget());
}
- iterator = windowWidgets.iterator();
+ iterable = windowWidgets;
} else if (widgetClassName.equals("VContextMenu")) {
return client.getContextMenu();
} else {
- iterator = (Iterator<? extends Widget>) parent.iterator();
+ iterable = (Iterable<? extends Widget>) parent;
}
boolean ok = false;
// Find the widgetPosition:th child of type "widgetClassName"
- while (iterator.hasNext()) {
+ for (Widget child : iterable) {
- Widget child = iterator.next();
String simpleName2 = Util.getSimpleName(child);
if (!widgetClassName.equals(simpleName2)
diff --git a/client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java b/client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java
index e70da1188c..1172704ba0 100644
--- a/client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java
+++ b/client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java
@@ -16,7 +16,6 @@
package com.vaadin.client.debug.internal;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -50,9 +49,8 @@ public class HierarchyPanel extends FlowPanel {
public void update() {
// Try to keep track of currently open nodes and reopen them
FastStringSet openNodes = FastStringSet.create();
- Iterator<Widget> it = iterator();
- while (it.hasNext()) {
- collectOpenNodes(it.next(), openNodes);
+ for (Widget widget : this) {
+ collectOpenNodes(widget, openNodes);
}
clear();
@@ -90,9 +88,8 @@ public class HierarchyPanel extends FlowPanel {
}
}
if (widget instanceof HasWidgets) {
- Iterator<Widget> it = ((HasWidgets) widget).iterator();
- while (it.hasNext()) {
- collectOpenNodes(it.next(), openNodes);
+ for (Widget child : (HasWidgets) widget) {
+ collectOpenNodes(child, openNodes);
}
}
}
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 d85643099c..26d3fd7be0 100644
--- a/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java
+++ b/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java
@@ -18,7 +18,6 @@ package com.vaadin.client.ui;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.List;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Element;
@@ -59,7 +58,7 @@ public class ShortcutActionHandler {
ShortcutActionHandler getShortcutActionHandler();
}
- private final List<ShortcutAction> actions = new ArrayList<>();
+ private final ArrayList<ShortcutAction> actions = new ArrayList<>();
private ApplicationConnection client;
private String paintableId;
@@ -101,17 +100,15 @@ public class ShortcutActionHandler {
public void handleKeyboardEvent(final Event event,
ComponentConnector target) {
- final int modifiers = KeyboardListenerCollection
- .getKeyboardModifiers(event);
final char keyCode = (char) DOM.eventGetKeyCode(event);
if (keyCode == 0) {
return;
}
+ final int modifiers = KeyboardListenerCollection
+ .getKeyboardModifiers(event);
final ShortcutKeyCombination kc = new ShortcutKeyCombination(keyCode,
modifiers);
- final Iterator<ShortcutAction> it = actions.iterator();
- while (it.hasNext()) {
- final ShortcutAction a = it.next();
+ for (final ShortcutAction a : actions) {
if (a.getShortcutCombination().equals(kc)) {
fireAction(event, a, target);
break;
diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java
index b1e5843125..da5d320c8d 100644
--- a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java
+++ b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java
@@ -17,7 +17,6 @@
package com.vaadin.client.ui;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -530,7 +529,8 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>>
updateControlButtonRangeStyles(needsMonth);
final String monthName = needsMonth
- ? getDateTimeService().getMonth(displayedMonth.getMonth()) : "";
+ ? getDateTimeService().getMonth(displayedMonth.getMonth())
+ : "";
final int year = displayedMonth.getYear() + 1900;
getFlexCellFormatter().setStyleName(0, 2,
@@ -1485,8 +1485,8 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>>
/**
* Returns the reset key which will reset the calendar to the previous
- * selection. By default this is backspace but it can be overridden to change
- * the key to whatever you want.
+ * selection. By default this is backspace but it can be overridden to
+ * change the key to whatever you want.
*
* @return
*/
@@ -1926,9 +1926,7 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>>
.parseInt(subPart.substring(SUBPART_DAY.length()));
Date date = new Date(displayedMonth.getYear(),
displayedMonth.getMonth(), dayOfMonth);
- Iterator<Widget> iter = days.iterator();
- while (iter.hasNext()) {
- Widget w = iter.next();
+ for (Widget w : days) {
if (w instanceof VAbstractCalendarPanel.Day) {
Day day = (Day) w;
if (day.getDate().equals(date)) {
@@ -1994,7 +1992,8 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>>
private void setLabel() {
if (getDateField() instanceof VAbstractPopupCalendar) {
- ((VAbstractPopupCalendar<?, ?>) getDateField()).setFocusedDate(this);
+ ((VAbstractPopupCalendar<?, ?>) getDateField())
+ .setFocusedDate(this);
}
}
}
diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java
index 9ae8115d8b..69d9e39529 100644
--- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java
+++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -1089,10 +1088,8 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
}
clearItems();
- final Iterator<ComboBoxSuggestion> it = suggestions.iterator();
boolean isFirstIteration = true;
- while (it.hasNext()) {
- final ComboBoxSuggestion suggestion = it.next();
+ for (final ComboBoxSuggestion suggestion : suggestions) {
final MenuItem mi = new MenuItem(suggestion.getDisplayString(),
true, suggestion);
String style = suggestion.getStyle();
diff --git a/client/src/main/java/com/vaadin/client/widgets/ChildFocusAwareFlowPanel.java b/client/src/main/java/com/vaadin/client/widgets/ChildFocusAwareFlowPanel.java
index 19ee7b8a21..0d430f8c7f 100644
--- a/client/src/main/java/com/vaadin/client/widgets/ChildFocusAwareFlowPanel.java
+++ b/client/src/main/java/com/vaadin/client/widgets/ChildFocusAwareFlowPanel.java
@@ -144,11 +144,11 @@ public class ChildFocusAwareFlowPanel extends FocusableFlowPanel
@Override
public void focus() {
- Iterator<Widget> iterator = iterator();
- if (iterator.hasNext()) {
- Widget widget = iterator.next();
- if (widget instanceof Focusable) {
- ((Focusable) widget).setFocus(true);
+ Iterator<Widget> it = iterator();
+ if (it.hasNext()) {
+ Widget child = it.next();
+ if (child instanceof Focusable) {
+ ((Focusable) child).setFocus(true);
}
}
}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java
index 2c2841042d..bb4acd257b 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java
@@ -17,7 +17,6 @@
package com.vaadin.v7.client.ui;
import java.util.Date;
-import java.util.Iterator;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.aria.client.SelectedValue;
@@ -450,7 +449,8 @@ public class VCalendarPanel extends FocusableFlexTable implements
updateControlButtonRangeStyles(needsMonth);
final String monthName = needsMonth
- ? getDateTimeService().getMonth(displayedMonth.getMonth()) : "";
+ ? getDateTimeService().getMonth(displayedMonth.getMonth())
+ : "";
final int year = displayedMonth.getYear() + 1900;
getFlexCellFormatter().setStyleName(0, 2,
@@ -1404,8 +1404,8 @@ public class VCalendarPanel extends FocusableFlexTable implements
/**
* Returns the reset key which will reset the calendar to the previous
- * selection. By default this is backspace but it can be overridden to change
- * the key to whatever you want.
+ * selection. By default this is backspace but it can be overridden to
+ * change the key to whatever you want.
*
* @return
*/
@@ -2138,9 +2138,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
.parseInt(subPart.substring(SUBPART_DAY.length()));
Date date = new Date(displayedMonth.getYear(),
displayedMonth.getMonth(), dayOfMonth);
- Iterator<Widget> iter = days.iterator();
- while (iter.hasNext()) {
- Widget w = iter.next();
+ for (Widget w : days) {
if (w instanceof Day) {
Day day = (Day) w;
if (day.getDate().equals(date)) {
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
index 3bc66e8390..0abee9b3b3 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -1092,10 +1091,8 @@ public class VFilterSelect extends Composite
}
clearItems();
- final Iterator<FilterSelectSuggestion> it = suggestions.iterator();
boolean isFirstIteration = true;
- while (it.hasNext()) {
- final FilterSelectSuggestion s = it.next();
+ for (final FilterSelectSuggestion s : suggestions) {
final MenuItem mi = new MenuItem(s.getDisplayString(), true, s);
String style = s.getStyle();
if (style != null) {
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
index 6150625547..4abcc75f4d 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
@@ -237,10 +237,8 @@ public class VOptionGroup extends VOptionGroupBase
@Override
public void setTabIndex(int tabIndex) {
- for (Iterator<Widget> iterator = panel.iterator(); iterator
- .hasNext();) {
- FocusWidget widget = (FocusWidget) iterator.next();
- widget.setTabIndex(tabIndex);
+ for (Widget widget : panel) {
+ ((FocusWidget) widget).setTabIndex(tabIndex);
}
}
@@ -269,9 +267,10 @@ public class VOptionGroup extends VOptionGroupBase
@Override
public void focus() {
- Iterator<Widget> iterator = panel.iterator();
- if (iterator.hasNext()) {
- ((Focusable) iterator.next()).setFocus(true);
+ Iterator<Widget> it = panel.iterator();
+ if (it.hasNext()) {
+ ((Focusable) it.next()).setFocus(true);
+
}
}
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 364afb0592..9894264126 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
@@ -1315,13 +1315,12 @@ public class VScrollTable extends FlowPanel
boolean updateFocus = rowsUnSelected || selectedRowKeys.size() == 0
|| focusedRow == null;
if (scrollBody != null) {
- Iterator<Widget> iterator = scrollBody.iterator();
- while (iterator.hasNext()) {
+ for (Widget w : scrollBody) {
/*
* Make the focus reflect to the server side state unless we
* are currently selecting multiple rows with keyboard.
*/
- VScrollTableRow row = (VScrollTableRow) iterator.next();
+ VScrollTableRow row = (VScrollTableRow) w;
boolean selected = selectedKeys.contains(row.getKey());
if (!selected && unSyncedselectionsBeforeRowFetch != null
&& unSyncedselectionsBeforeRowFetch
@@ -2034,10 +2033,8 @@ public class VScrollTable extends FlowPanel
*/
public VScrollTableRow getRenderedRowByKey(String key) {
if (scrollBody != null) {
- final Iterator<Widget> it = scrollBody.iterator();
- VScrollTableRow r = null;
- while (it.hasNext()) {
- r = (VScrollTableRow) it.next();
+ for (Widget w : scrollBody) {
+ VScrollTableRow r = (VScrollTableRow) w;
if (r.getKey().equals(key)) {
return r;
}
@@ -2056,9 +2053,8 @@ public class VScrollTable extends FlowPanel
*/
private VScrollTableRow getNextRow(VScrollTableRow row, int offset) {
final Iterator<Widget> it = scrollBody.iterator();
- VScrollTableRow r = null;
while (it.hasNext()) {
- r = (VScrollTableRow) it.next();
+ VScrollTableRow r = (VScrollTableRow) it.next();
if (r == row) {
r = null;
while (offset >= 0 && it.hasNext()) {
@@ -2082,10 +2078,9 @@ public class VScrollTable extends FlowPanel
private VScrollTableRow getPreviousRow(VScrollTableRow row, int offset) {
final Iterator<Widget> it = scrollBody.iterator();
final Iterator<Widget> offsetIt = scrollBody.iterator();
- VScrollTableRow r = null;
VScrollTableRow prev = null;
while (it.hasNext()) {
- r = (VScrollTableRow) it.next();
+ VScrollTableRow r = (VScrollTableRow) it.next();
if (offset < 0) {
prev = (VScrollTableRow) offsetIt.next();
}
@@ -3452,11 +3447,11 @@ public class VScrollTable extends FlowPanel
}
if (columnIndex < 0) {
columnIndex = 0;
- for (Iterator<Widget> it = tHead.iterator(); it
- .hasNext(); columnIndex++) {
- if (it.next() == this) {
+ for (Widget w : tHead) {
+ if (w == this) {
break;
}
+ columnIndex++;
}
}
final int cw = scrollBody.getColWidth(columnIndex);
@@ -4079,11 +4074,10 @@ public class VScrollTable extends FlowPanel
* Returns column alignments for visible columns
*/
public char[] getColumnAlignments() {
- final Iterator<Widget> it = visibleCells.iterator();
final char[] aligns = new char[visibleCells.size()];
int colIndex = 0;
- while (it.hasNext()) {
- aligns[colIndex++] = ((HeaderCell) it.next()).getAlign();
+ for (Widget w : visibleCells) {
+ aligns[colIndex++] = ((HeaderCell) w).getAlign();
}
return aligns;
}
@@ -5439,9 +5433,8 @@ public class VScrollTable extends FlowPanel
public void moveCol(int oldIndex, int newIndex) {
// loop all rows and move given index to its new place
- final Iterator<?> rows = iterator();
- while (rows.hasNext()) {
- final VScrollTableRow row = (VScrollTableRow) rows.next();
+ for (Widget w : this) {
+ final VScrollTableRow row = (VScrollTableRow) w;
final Element td = DOM.getChild(row.getElement(), oldIndex);
if (td != null) {
@@ -6921,7 +6914,6 @@ public class VScrollTable extends FlowPanel
return;
}
- Iterator<Widget> headCells = tHead.iterator();
int usedMinimumWidth = 0;
int totalExplicitColumnsWidths = 0;
float expandRatioDivider = 0;
@@ -6931,8 +6923,8 @@ public class VScrollTable extends FlowPanel
int hierarchyColumnIndex = getHierarchyColumnIndex();
HeaderCell hierarchyHeaderInNeedOfFurtherHandling = null;
- while (headCells.hasNext()) {
- final HeaderCell hCell = (HeaderCell) headCells.next();
+ for (Widget widget : tHead) {
+ final HeaderCell hCell = (HeaderCell) widget;
boolean hasIndent = hierarchyColumnIndent > 0
&& hCell.isHierarchyColumn();
if (hCell.isDefinedWidth()) {
@@ -7049,12 +7041,10 @@ public class VScrollTable extends FlowPanel
}
// we have some space that can be divided optimally
- HeaderCell hCell;
colIndex = 0;
- headCells = tHead.iterator();
int checksum = 0;
- while (headCells.hasNext()) {
- hCell = (HeaderCell) headCells.next();
+ for (Widget widget : tHead) {
+ HeaderCell hCell = (HeaderCell) widget;
if (hCell.isResizing) {
continue;
}
@@ -7107,10 +7097,9 @@ public class VScrollTable extends FlowPanel
* extra space is divided so if there is one then we give the
* first undefined column 1 more pixel
*/
- headCells = tHead.iterator();
colIndex = 0;
- while (headCells.hasNext()) {
- HeaderCell hc = (HeaderCell) headCells.next();
+ for (Widget widget : tHead) {
+ HeaderCell hc = (HeaderCell) widget;
if (!hc.isResizing && !hc.isDefinedWidth()) {
setColWidth(colIndex,
hc.getWidthWithIndent() + availW - checksum,
@@ -7554,12 +7543,11 @@ public class VScrollTable extends FlowPanel
private Class<? extends Widget> getRowClass() {
// get the row type this way to make dd work in derived
// implementations
- Iterator<Widget> iterator = scrollBody.iterator();
- if (iterator.hasNext()) {
- return iterator.next().getClass();
- } else {
- return null;
+ Iterator<Widget> it = scrollBody.iterator();
+ if (it.hasNext()) {
+ return it.next().getClass();
}
+ return null;
}
@Override
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java
index acfbb02d70..2dce082305 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java
@@ -19,7 +19,6 @@ package com.vaadin.v7.client.ui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -1016,9 +1015,8 @@ public class VTree extends FocusElementPanel
List<TreeNode> nodes = new LinkedList<TreeNode>();
if (!isLeaf() && isChildrenLoaded()) {
- Iterator<Widget> iter = childNodeContainer.iterator();
- while (iter.hasNext()) {
- TreeNode node = (TreeNode) iter.next();
+ for (Widget w : childNodeContainer) {
+ TreeNode node = (TreeNode) w;
nodes.add(node);
}
}
@@ -1489,10 +1487,8 @@ public class VTree extends FocusElementPanel
endNode = temp;
}
- Iterator<TreeNode> childIter = children.iterator();
boolean startFound = false;
- while (childIter.hasNext()) {
- TreeNode node = childIter.next();
+ for (TreeNode node : children) {
if (node == startNode) {
startFound = true;
}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java
index dc76d6cd2d..99caa8bf44 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java
@@ -428,9 +428,8 @@ public class VTreeTable extends VScrollTable {
@Override
protected void calculateMaxIndent() {
int maxIndent = 0;
- Iterator<Widget> iterator = iterator();
- while (iterator.hasNext()) {
- VTreeTableRow next = (VTreeTableRow) iterator.next();
+ for (Widget w : this) {
+ VTreeTableRow next = (VTreeTableRow) w;
maxIndent = Math.max(maxIndent, next.getIndent());
}
this.maxIndent = maxIndent;
@@ -442,10 +441,8 @@ public class VTreeTable extends VScrollTable {
indentWidth = -1;
return;
}
- Iterator<Widget> iterator = iterator();
- while (iterator.hasNext()) {
- VTreeTableRow next = (VTreeTableRow) iterator.next();
- next.setIndent();
+ for (Widget w : this) {
+ ((VTreeTableRow) w).setIndent();
}
calculateMaxIndent();
}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DayToolbar.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DayToolbar.java
index 4d7d1631c2..b7e152c010 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DayToolbar.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DayToolbar.java
@@ -15,8 +15,6 @@
*/
package com.vaadin.v7.client.ui.calendar.schedule;
-import java.util.Iterator;
-
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -158,9 +156,8 @@ public class DayToolbar extends HorizontalPanel implements ClickHandler {
}
private void updateDayLabelSizedStyleNames() {
- Iterator<Widget> it = iterator();
- while (it.hasNext()) {
- updateWidgetSizedStyleName(it.next());
+ for (Widget w : this) {
+ updateWidgetSizedStyleName(w);
}
}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java
index 091951bc8b..b4a00559b1 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java
@@ -16,7 +16,6 @@
package com.vaadin.v7.client.ui.table;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import com.google.gwt.core.client.Scheduler;
@@ -190,7 +189,8 @@ public class TableConnector extends AbstractFieldConnector
// Update child measure hint
int childMeasureHint = uidl.hasAttribute("measurehint")
- ? uidl.getIntAttribute("measurehint") : 0;
+ ? uidl.getIntAttribute("measurehint")
+ : 0;
getWidget().setChildMeasurementHint(
ChildMeasurementHint.values()[childMeasureHint]);
@@ -451,9 +451,7 @@ public class TableConnector extends AbstractFieldConnector
*/
public void showSavedContextMenu(ContextMenuDetails savedContextMenu) {
if (isEnabled() && savedContextMenu != null) {
- Iterator<Widget> iterator = getWidget().scrollBody.iterator();
- while (iterator.hasNext()) {
- Widget w = iterator.next();
+ for (Widget w : getWidget().scrollBody) {
VScrollTableRow row = (VScrollTableRow) w;
if (row.getKey().equals(savedContextMenu.rowKey)) {
row.showContextMenu(savedContextMenu.left,
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java
index 2e93c2249f..7bb965846b 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java
@@ -18,7 +18,6 @@ package com.vaadin.v7.data.util;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -846,9 +845,8 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
model.remove(propertyId);
// If remove the Property from all Items
- for (final Iterator<IDTYPE> i = getAllItemIds().iterator(); i
- .hasNext();) {
- getUnfilteredItem(i.next()).removeItemProperty(propertyId);
+ for (final IDTYPE id : getAllItemIds()) {
+ getUnfilteredItem(id).removeItemProperty(propertyId);
}
// Sends a change event
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java
index 61d9d4f55f..3a1c179c34 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java
@@ -525,9 +525,7 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE
// Filter
boolean equal = true;
Iterator<ITEMIDTYPE> origIt = originalFilteredItemIds.iterator();
- for (final Iterator<ITEMIDTYPE> i = getAllItemIds().iterator(); i
- .hasNext();) {
- final ITEMIDTYPE id = i.next();
+ for (final ITEMIDTYPE id : getAllItemIds()) {
if (passesFilters(id)) {
// filtered list comes from the full list, can use ==
equal = equal && origIt.hasNext() && origIt.next() == id;
@@ -554,9 +552,7 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE
if (getFilters().isEmpty()) {
return true;
}
- final Iterator<Filter> i = getFilters().iterator();
- while (i.hasNext()) {
- final Filter f = i.next();
+ for (final Filter f : getFilters()) {
if (!f.passesFilter(itemId, item)) {
return false;
}
@@ -644,9 +640,7 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE
if (getFilters().isEmpty() || propertyId == null) {
return false;
}
- final Iterator<Filter> i = getFilters().iterator();
- while (i.hasNext()) {
- final Filter f = i.next();
+ for (final Filter f : getFilters()) {
if (f.appliesToProperty(propertyId)) {
return true;
}
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 a4e9d74c53..e9f160dedd 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
@@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
@@ -167,8 +166,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical,
s.addAll(roots);
// Remove unnecessary items
- for (final Iterator<Object> i = s.iterator(); i.hasNext();) {
- final Object id = i.next();
+ for (final Object id : s) {
if (!container.containsId(id)) {
removeFromHierarchyWrapper(id);
}
@@ -176,8 +174,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical,
// Add all the missing items
final Collection<?> ids = container.getItemIds();
- for (final Iterator<?> i = ids.iterator(); i.hasNext();) {
- final Object id = i.next();
+ for (final Object id : ids) {
if (!s.contains(id)) {
addToHierarchyWrapper(id);
s.add(id);
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerOrderedWrapper.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerOrderedWrapper.java
index f7da00acd9..8979e7a5d6 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerOrderedWrapper.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/ContainerOrderedWrapper.java
@@ -19,7 +19,6 @@ package com.vaadin.v7.data.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -226,16 +225,14 @@ public class ContainerOrderedWrapper implements Container.Ordered,
// Filter out all the missing items
final LinkedList<?> l = new LinkedList<Object>(next.keySet());
- for (final Iterator<?> i = l.iterator(); i.hasNext();) {
- final Object id = i.next();
+ for (final Object id : l) {
if (!container.containsId(id)) {
removeFromOrderWrapper(id);
}
}
// Adds missing items
- for (final Iterator<?> i = ids.iterator(); i.hasNext();) {
- final Object id = i.next();
+ for (final Object id : ids) {
if (!next.containsKey(id) && last != id) {
addToOrderWrapper(id);
}
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 1799bdc72e..9fca1061fd 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
@@ -26,7 +26,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -428,8 +427,7 @@ public class FilesystemContainer implements Container.Hierarchical {
final List<File> ll = Arrays.asList(l);
Collections.sort(ll);
- for (final Iterator<File> i = ll.iterator(); i.hasNext();) {
- final File lf = i.next();
+ for (final File lf : ll) {
col.add(lf);
if (lf.isDirectory()) {
addItemIds(col, lf);
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/ListSet.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/ListSet.java
index 4c40c8c81a..291397cd63 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/ListSet.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/ListSet.java
@@ -20,7 +20,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
/**
@@ -106,9 +105,7 @@ public class ListSet<E> extends ArrayList<E> {
@Override
public boolean addAll(Collection<? extends E> c) {
boolean modified = false;
- Iterator<? extends E> i = c.iterator();
- while (i.hasNext()) {
- E e = i.next();
+ for (E e : c) {
if (contains(e)) {
continue;
}
@@ -126,9 +123,7 @@ public class ListSet<E> extends ArrayList<E> {
ensureCapacity(size() + c.size());
boolean modified = false;
- Iterator<? extends E> i = c.iterator();
- while (i.hasNext()) {
- E e = i.next();
+ for (E e : c) {
if (contains(e)) {
continue;
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java
index ed65e621ec..da1122a3d9 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java
@@ -15,14 +15,11 @@
*/
package com.vaadin.v7.data.util.converter;
-import com.vaadin.data.Binder;
-
import java.io.Serializable;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Locale;
/**
@@ -41,7 +38,8 @@ import java.util.Locale;
* @author Vaadin Ltd
*
* @deprecated As of 8.0, a lightweight lambda-based converter can be build with
- * {@link Binder}{@code .forField(...).withConverter(...)} methods.
+ * {@link com.vaadin.data.Binder
+ * Binder}{@code .forField(...).withConverter(...)} methods.
*/
@Deprecated
public class StringToCollectionConverter
@@ -178,12 +176,12 @@ public class StringToCollectionConverter
}
StringBuilder builder = new StringBuilder();
Converter converter = tokenConverter;
- for (Iterator<?> iterator = value.iterator(); iterator.hasNext();) {
+ for (Object o : value) {
if (converter == null) {
- builder.append(iterator.next());
+ builder.append(o);
} else {
- builder.append(converter.convertToPresentation(iterator.next(),
- targetType, locale));
+ builder.append(
+ converter.convertToPresentation(o, targetType, locale));
}
builder.append(delimiter);
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java
index 653ad3f6bf..066dd78c11 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java
@@ -21,11 +21,9 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
-import java.util.logging.Logger;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
@@ -652,9 +650,8 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
final Collection<Validator> validators = ((Validatable) dataSource)
.getValidators();
if (validators != null) {
- for (final Iterator<Validator> i = validators.iterator(); i
- .hasNext();) {
- addValidator(i.next());
+ for (final Validator v : validators) {
+ addValidator(v);
}
}
}
@@ -1766,8 +1763,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
@Override
public void writeDesign(Element design, DesignContext designContext) {
super.writeDesign(design, designContext);
- AbstractField<?> def = designContext
- .getDefaultInstance(this);
+ AbstractField<?> def = designContext.getDefaultInstance(this);
Attributes attr = design.attributes();
// handle readonly
DesignAttributeHandler.writeAttribute("readonly", attr,
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 894936e1cd..a6472c61db 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
@@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.EventObject;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
@@ -404,11 +403,9 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
target.endTag("so");
}
- final Iterator<?> i = getItemIds().iterator();
// Paints the available selection options from data source
- while (i.hasNext()) {
+ for (final Object id : getItemIds()) {
// Gets the option attribute values
- final Object id = i.next();
if (!isNullSelectionAllowed() && id != null
&& id.equals(getNullSelectionItemId())) {
// Remove item if it's the null selection item but null
@@ -1941,8 +1938,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
}
Collection<?> pids = i.getItemPropertyIds();
if (pids != null) {
- for (Iterator<?> it = pids.iterator(); it.hasNext();) {
- Property<?> p = i.getItemProperty(it.next());
+ for (Object id : pids) {
+ Property<?> p = i.getItemProperty(id);
if (p != null
&& p instanceof Property.ValueChangeNotifier) {
((Property.ValueChangeNotifier) p)
@@ -1977,9 +1974,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
}
public void clear() {
- for (Iterator<Object> it = captionChangeNotifiers.iterator(); it
- .hasNext();) {
- Object notifier = it.next();
+ for (Object notifier : captionChangeNotifiers) {
if (notifier instanceof Item.PropertySetChangeNotifier) {
((Item.PropertySetChangeNotifier) notifier)
.removePropertySetChangeListener(
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
index b9960bba4f..d180aa34b9 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
@@ -19,7 +19,6 @@ package com.vaadin.v7.ui;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -286,12 +285,9 @@ public class ComboBox extends AbstractSelect
target.endTag("so");
}
- final Iterator<?> i = options.iterator();
// Paints the available selection options from data source
- while (i.hasNext()) {
-
- final Object id = i.next();
+ for (final Object id : options) {
if (!isNullSelectionAllowed() && id != null
&& id.equals(getNullSelectionItemId())
@@ -690,8 +686,7 @@ public class ComboBox extends AbstractSelect
prevfilterstring = filterstring;
filteredOptions = new LinkedList<Object>();
- for (final Iterator<?> it = items.iterator(); it.hasNext();) {
- final Object itemId = it.next();
+ for (final Object itemId : items) {
String caption = getItemCaption(itemId);
if (caption == null || caption.equals("")) {
continue;
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java
index 63a6118c58..b37bcd933b 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java
@@ -245,9 +245,8 @@ public class Form extends AbstractField<Object>
// getErrorMessage() recursively instead of validate().
ErrorMessage validationError = null;
if (isValidationVisible()) {
- for (final Iterator<Object> i = propertyIds.iterator(); i
- .hasNext();) {
- Object f = fields.get(i.next());
+ for (final Object id : propertyIds) {
+ Object f = fields.get(id);
if (f instanceof AbstractComponent) {
AbstractComponent field = (AbstractComponent) f;
@@ -337,9 +336,9 @@ public class Form extends AbstractField<Object>
}
// Try to commit all
- for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
+ for (final Object id : propertyIds) {
try {
- final Field<?> f = fields.get(i.next());
+ final Field<?> f = fields.get(id);
// Commit only non-readonly fields.
if (!f.isReadOnly()) {
f.commit();
@@ -362,12 +361,9 @@ public class Form extends AbstractField<Object>
}
// Commit problems
- final Throwable[] causes = new Throwable[problems.size()];
- int index = 0;
- for (final Iterator<SourceException> i = problems.iterator(); i
- .hasNext();) {
- causes[index++] = i.next();
- }
+ final Throwable[] causes = problems
+ .toArray(new Throwable[problems.size()]);
+
final Buffered.SourceException e = new Buffered.SourceException(this,
causes);
currentBufferedSourceException = e;
@@ -385,9 +381,9 @@ public class Form extends AbstractField<Object>
LinkedList<SourceException> problems = null;
// Try to discard all changes
- for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
+ for (final Object id : propertyIds) {
try {
- fields.get(i.next()).discard();
+ fields.get(id).discard();
} catch (final Buffered.SourceException e) {
if (problems == null) {
problems = new LinkedList<SourceException>();
@@ -406,12 +402,9 @@ public class Form extends AbstractField<Object>
}
// Discards problems occurred
- final Throwable[] causes = new Throwable[problems.size()];
- int index = 0;
- for (final Iterator<SourceException> i = problems.iterator(); i
- .hasNext();) {
- causes[index++] = i.next();
- }
+ final Throwable[] causes = problems
+ .toArray(new Throwable[problems.size()]);
+
final Buffered.SourceException e = new Buffered.SourceException(this,
causes);
currentBufferedSourceException = e;
@@ -425,8 +418,8 @@ public class Form extends AbstractField<Object>
*/
@Override
public boolean isModified() {
- for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
- final Field<?> f = fields.get(i.next());
+ for (final Object id : propertyIds) {
+ final Field<?> f = fields.get(id);
if (f != null && f.isModified()) {
return true;
}
@@ -443,9 +436,8 @@ public class Form extends AbstractField<Object>
public void setBuffered(boolean buffered) {
if (buffered != this.buffered) {
this.buffered = buffered;
- for (final Iterator<Object> i = propertyIds.iterator(); i
- .hasNext();) {
- fields.get(i.next()).setBuffered(buffered);
+ for (final Object id : propertyIds) {
+ fields.get(id).setBuffered(buffered);
}
}
}
@@ -741,8 +733,7 @@ public class Form extends AbstractField<Object>
}
// Adds all the properties to this form
- for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) {
- final Object id = i.next();
+ for (final Object id : propertyIds) {
final Property<?> property = itemDatasource.getItemProperty(id);
if (id != null && property != null) {
final Field<?> f = fieldFactory.createField(itemDatasource, id,
@@ -890,9 +881,7 @@ public class Form extends AbstractField<Object>
}
if (value != null && !found) {
if (value instanceof Collection) {
- for (final Iterator<?> it = ((Collection<?>) value)
- .iterator(); it.hasNext();) {
- final Object val = it.next();
+ for (final Object val : ((Collection<?>) value)) {
found = false;
for (int i = 0; i < values.length && !found; i++) {
if (values[i] == val
@@ -965,8 +954,8 @@ public class Form extends AbstractField<Object>
@Override
public void validate() throws InvalidValueException {
super.validate();
- for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
- fields.get(i.next()).validate();
+ for (final Object id : propertyIds) {
+ fields.get(id).validate();
}
}
@@ -999,8 +988,8 @@ public class Form extends AbstractField<Object>
@Override
public void setReadOnly(boolean readOnly) {
super.setReadOnly(readOnly);
- for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) {
- fields.get(i.next()).setReadOnly(readOnly);
+ for (final Object id : propertyIds) {
+ fields.get(id).setReadOnly(readOnly);
}
}
@@ -1179,9 +1168,8 @@ public class Form extends AbstractField<Object>
@Override
public void setTabIndex(int tabIndex) {
super.setTabIndex(tabIndex);
- for (final Iterator<?> i = getItemPropertyIds().iterator(); i
- .hasNext();) {
- getField(i.next()).setTabIndex(tabIndex);
+ for (final Object id : getItemPropertyIds()) {
+ getField(id).setTabIndex(tabIndex);
}
}
@@ -1192,8 +1180,7 @@ public class Form extends AbstractField<Object>
@Override
public void setImmediate(boolean immediate) {
super.setImmediate(immediate);
- for (Iterator<Field<?>> i = fields.values().iterator(); i.hasNext();) {
- Field<?> f = i.next();
+ for (Field<?> f : fields.values()) {
if (f instanceof AbstractLegacyComponent) {
((AbstractLegacyComponent) f).setImmediate(immediate);
}
@@ -1208,9 +1195,7 @@ public class Form extends AbstractField<Object>
*/
@Override
public boolean isEmpty() {
-
- for (Iterator<Field<?>> i = fields.values().iterator(); i.hasNext();) {
- Field<?> f = i.next();
+ for (Field<?> f : fields.values()) {
if (f instanceof AbstractField) {
if (!((AbstractField<?>) f).isEmpty()) {
return false;
@@ -1223,8 +1208,7 @@ public class Form extends AbstractField<Object>
@Override
public void clear() {
- for (Iterator<Field<?>> i = fields.values().iterator(); i.hasNext();) {
- Field<?> f = i.next();
+ for (Field<?> f : fields.values()) {
if (f instanceof AbstractField) {
((AbstractField<?>) f).clear();
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java
index 387c4eebf4..4349ad49b4 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java
@@ -1792,10 +1792,11 @@ public class Grid extends AbstractComponent
selection);
if (selection.size() + itemIds.size() >= selectionLimit) {
// Add one at a time if there's a risk of overflow
- Iterator<?> iterator = itemIds.iterator();
- while (iterator.hasNext()
- && selection.size() < selectionLimit) {
- selection.add(iterator.next());
+ for (Object id : itemIds) {
+ if (selection.size() >= selectionLimit) {
+ break;
+ }
+ selection.add(id);
}
} else {
selection.addAll(itemIds);
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 c99757ee04..9002f11c77 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
@@ -738,9 +738,8 @@ public class Table extends AbstractSelect implements Action.Container,
}
final String[] headers = new String[visibleColumns.size()];
int i = 0;
- for (final Iterator<Object> it = visibleColumns.iterator(); it
- .hasNext(); i++) {
- headers[i] = getColumnHeader(it.next());
+ for (final Object column : visibleColumns) {
+ headers[i++] = getColumnHeader(column);
}
return headers;
}
@@ -770,9 +769,11 @@ public class Table extends AbstractSelect implements Action.Container,
this.columnHeaders.clear();
int i = 0;
- for (final Iterator<Object> it = visibleColumns.iterator(); it.hasNext()
- && i < columnHeaders.length; i++) {
- this.columnHeaders.put(it.next(), columnHeaders[i]);
+ for (final Object column : visibleColumns) {
+ if (i >= columnHeaders.length) {
+ break;
+ }
+ this.columnHeaders.put(column, columnHeaders[i++]);
}
markAsDirty();
@@ -797,9 +798,8 @@ public class Table extends AbstractSelect implements Action.Container,
}
final Resource[] icons = new Resource[visibleColumns.size()];
int i = 0;
- for (final Iterator<Object> it = visibleColumns.iterator(); it
- .hasNext(); i++) {
- icons[i] = columnIcons.get(it.next());
+ for (final Object column : visibleColumns) {
+ icons[i++] = columnIcons.get(column);
}
return icons;
@@ -829,9 +829,11 @@ public class Table extends AbstractSelect implements Action.Container,
this.columnIcons.clear();
int i = 0;
- for (final Iterator<Object> it = visibleColumns.iterator(); it.hasNext()
- && i < columnIcons.length; i++) {
- this.columnIcons.put(it.next(), columnIcons[i]);
+ for (final Object column : visibleColumns) {
+ if (i >= columnIcons.length) {
+ break;
+ }
+ this.columnIcons.put(column, columnIcons[i++]);
}
markAsDirty();
@@ -861,9 +863,8 @@ public class Table extends AbstractSelect implements Action.Container,
}
final Align[] alignments = new Align[visibleColumns.size()];
int i = 0;
- for (final Iterator<Object> it = visibleColumns.iterator(); it
- .hasNext(); i++) {
- alignments[i] = getColumnAlignment(it.next());
+ for (final Object column : visibleColumns) {
+ alignments[i++] = getColumnAlignment(column);
}
return alignments;
@@ -897,9 +898,11 @@ public class Table extends AbstractSelect implements Action.Container,
// Resets the alignments
final Map<Object, Align> newCA = new HashMap<Object, Align>();
int i = 0;
- for (final Iterator<Object> it = visibleColumns.iterator(); it.hasNext()
- && i < columnAlignments.length; i++) {
- newCA.put(it.next(), columnAlignments[i]);
+ for (final Object column : visibleColumns) {
+ if (i >= columnAlignments.length) {
+ break;
+ }
+ newCA.put(column, columnAlignments[i++]);
}
this.columnAlignments = newCA;
@@ -1480,9 +1483,7 @@ public class Table extends AbstractSelect implements Action.Container,
newOrder.add(columnOrder[i]);
}
}
- for (final Iterator<Object> it = visibleColumns.iterator(); it
- .hasNext();) {
- final Object columnId = it.next();
+ for (final Object columnId : visibleColumns) {
if (!newOrder.contains(columnId)) {
newOrder.add(columnId);
}
@@ -2476,9 +2477,7 @@ public class Table extends AbstractSelect implements Action.Container,
HashSet<Property<?>> oldListenedProperties,
HashSet<Component> oldVisibleComponents) {
if (oldVisibleComponents != null) {
- for (final Iterator<Component> i = oldVisibleComponents
- .iterator(); i.hasNext();) {
- Component c = i.next();
+ for (final Component c : oldVisibleComponents) {
if (!visibleComponents.contains(c)) {
unregisterComponent(c);
}
@@ -2486,9 +2485,8 @@ public class Table extends AbstractSelect implements Action.Container,
}
if (oldListenedProperties != null) {
- for (final Iterator<Property<?>> i = oldListenedProperties
- .iterator(); i.hasNext();) {
- Property.ValueChangeNotifier o = (ValueChangeNotifier) i.next();
+ for (final Property<?> p : oldListenedProperties) {
+ Property.ValueChangeNotifier o = (ValueChangeNotifier) p;
if (!listenedProperties.contains(o)) {
o.removeListener(this);
}
@@ -2601,8 +2599,7 @@ public class Table extends AbstractSelect implements Action.Container,
// remove generated columns from the list of columns being assigned
final LinkedList<Object> availableCols = new LinkedList<Object>();
- for (Iterator<Object> it = visibleColumns.iterator(); it.hasNext();) {
- Object id = it.next();
+ for (Object id : visibleColumns) {
if (!columnGenerators.containsKey(id)) {
availableCols.add(id);
}
@@ -2776,8 +2773,7 @@ public class Table extends AbstractSelect implements Action.Container,
// don't add the same id twice
Collection<Object> col = new LinkedList<Object>();
- for (Iterator<?> it = visibleIds.iterator(); it.hasNext();) {
- Object id = it.next();
+ for (Object id : visibleIds) {
if (!col.contains(id)) {
col.add(id);
}
@@ -3040,9 +3036,7 @@ public class Table extends AbstractSelect implements Action.Container,
for (Object id : ids) {
idSet.add(columnIdMap.get(id.toString()));
}
- for (final Iterator<Object> it = visibleColumns
- .iterator(); it.hasNext();) {
- Object propertyId = it.next();
+ for (final Object propertyId : visibleColumns) {
if (isColumnCollapsed(propertyId)) {
if (!idSet.contains(propertyId)) {
setColumnCollapsed(propertyId, false);
@@ -3803,8 +3797,7 @@ public class Table extends AbstractSelect implements Action.Container,
if (isMultiSelect()) {
HashSet<?> sel = new HashSet<Object>((Set<?>) getValue());
Collection<?> vids = getVisibleItemIds();
- for (Iterator<?> it = vids.iterator(); it.hasNext();) {
- Object id = it.next();
+ for (Object id : vids) {
if (sel.contains(id)) {
selectedKeys.add(itemIdMapper.key(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 6b3a4497c8..6a2da71bb7 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
@@ -780,10 +780,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
// Actions
if (actionHandlers != null) {
final List<String> keys = new ArrayList<String>();
- final Iterator<Action.Handler> ahi = actionHandlers
- .iterator();
- while (ahi.hasNext()) {
- final Action[] aa = ahi.next().getActions(itemId, this);
+ for (Action.Handler ah : actionHandlers) {
+ final Action[] aa = ah.getActions(itemId, this);
if (aa != null) {
for (int ai = 0; ai < aa.length; ai++) {
final String akey = actionMapper.key(aa[ai]);
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java
index 6ded53b3a1..a9a09ae49b 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java
@@ -20,7 +20,6 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
@@ -926,9 +925,7 @@ public class Upload extends AbstractLegacyComponent
// this is implemented differently than other listeners to maintain
// backwards compatibility
if (progressListeners != null) {
- for (Iterator<ProgressListener> it = progressListeners
- .iterator(); it.hasNext();) {
- ProgressListener l = it.next();
+ for (ProgressListener l : progressListeners) {
l.updateProgress(totalBytes, contentLength);
}
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerHistory.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerHistory.java
index 09a7de6aff..0cab53c13e 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerHistory.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerHistory.java
@@ -118,14 +118,7 @@ public class ColorPickerHistory extends CustomComponent
ArrayBlockingQueue<Color> colorHistory = getColorHistory();
// Check that the color does not already exist
- boolean exists = false;
- Iterator<Color> iter = colorHistory.iterator();
- while (iter.hasNext()) {
- if (color.equals(iter.next())) {
- exists = true;
- break;
- }
- }
+ boolean exists = colorHistory.contains(color);
// If the color does not exist then add it
if (!exists) {
@@ -145,7 +138,7 @@ public class ColorPickerHistory extends CustomComponent
// Create 2d color map
Color[][] colors = new Color[rows][columns];
- iter = colorList.iterator();
+ Iterator<Color> iter = colorList.iterator();
for (int row = 0; row < rows; row++) {
for (int col = 0; col < columns; col++) {
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java
index 306c4e78aa..71d8ef7a2c 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java
@@ -19,7 +19,6 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
@@ -479,7 +478,7 @@ public class ColorPickerPopup extends Window
}
resize.setData(new Boolean(!state));
- } else if (event.getButton() == ok) {
+ } else if (event.getButton() == ok) {
// Ok button was clicked
history.setColor(getColor());
fireColorChanged();
@@ -599,9 +598,8 @@ public class ColorPickerPopup extends Window
* @return true if tab is visible, false otherwise
*/
private boolean tabIsVisible(Component tab) {
- Iterator<Component> tabIterator = tabs.getComponentIterator();
- while (tabIterator.hasNext()) {
- if (tabIterator.next() == tab) {
+ for (Component comp : tabs) {
+ if (comp == tab) {
return true;
}
}
@@ -614,10 +612,8 @@ public class ColorPickerPopup extends Window
* @return The number of tabs visible
*/
private int tabsNumVisible() {
- Iterator<Component> tabIterator = tabs.getComponentIterator();
int tabCounter = 0;
- while (tabIterator.hasNext()) {
- tabIterator.next();
+ for (Component comp : tabs) {
tabCounter++;
}
return tabCounter;
diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java
index 31d96fb47e..dee7c3fee3 100644
--- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java
+++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java
@@ -9,7 +9,6 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -60,9 +59,8 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
beanItemContainer.removeAllItems();
- Iterator<ClassName> it = nameToBean.values().iterator();
- while (it.hasNext()) {
- beanItemContainer.addBean(it.next());
+ for (ClassName name : nameToBean.values()) {
+ beanItemContainer.addBean(name);
}
}
diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/ContainerSortingTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/ContainerSortingTest.java
index 860f3b7b15..539835f1c5 100644
--- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/ContainerSortingTest.java
+++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/ContainerSortingTest.java
@@ -1,7 +1,6 @@
package com.vaadin.v7.data.util;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.junit.Test;
@@ -154,10 +153,8 @@ public class ContainerSortingTest {
private void verifyOrder(Container.Sortable ic, Object[] idOrder) {
int size = ic.size();
Object[] actual = new Object[size];
- Iterator<?> i = ic.getItemIds().iterator();
int index = 0;
- while (i.hasNext()) {
- Object o = i.next();
+ for (Object o : ic.getItemIds()) {
if (o.getClass() == Integer.class
&& idOrder[index].getClass() == String.class) {
o = idToName.get(o);
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 65e3413122..66ba4d0d9f 100644
--- a/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java
+++ b/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java
@@ -24,7 +24,6 @@ import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -533,9 +532,7 @@ public class ClassPathExplorer {
}
URL firstDirectory = null;
- Iterator<String> it = rawClasspathEntries.iterator();
- while (it.hasNext()) {
- String entry = it.next();
+ for (String entry : rawClasspathEntries) {
File directory = new File(entry);
if (directory.exists() && !directory.isHidden()
diff --git a/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java b/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java
index fc01891b2e..608f84782c 100644
--- a/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java
+++ b/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java
@@ -29,7 +29,6 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -116,9 +115,7 @@ public class WidgetSetBuilder {
content);
// add widgetsets that do not exist
- Iterator<String> i = availableWidgetSets.keySet().iterator();
- while (i.hasNext()) {
- String ws = i.next();
+ for (String ws : availableWidgetSets.keySet()) {
if (ws.equals(widgetset)) {
// do not inherit the module itself
continue;
diff --git a/server/src/main/java/com/vaadin/ui/ConnectorTracker.java b/server/src/main/java/com/vaadin/ui/ConnectorTracker.java
index a128e24e95..2ac5e33f34 100644
--- a/server/src/main/java/com/vaadin/ui/ConnectorTracker.java
+++ b/server/src/main/java/com/vaadin/ui/ConnectorTracker.java
@@ -399,10 +399,9 @@ public class ConnectorTracker implements Serializable {
}
private static boolean hasVisibleChild(ClientConnector parent) {
- Iterator<? extends ClientConnector> iterator = AbstractClientConnector
- .getAllChildrenIterable(parent).iterator();
- while (iterator.hasNext()) {
- ClientConnector child = iterator.next();
+ Iterable<? extends ClientConnector> iterable = AbstractClientConnector
+ .getAllChildrenIterable(parent);
+ for (ClientConnector child : iterable) {
if (LegacyCommunicationManager.isConnectorVisibleToClient(child)) {
return true;
}
diff --git a/server/src/main/java/com/vaadin/ui/GridLayout.java b/server/src/main/java/com/vaadin/ui/GridLayout.java
index b4d97018ce..b7bbcd061b 100644
--- a/server/src/main/java/com/vaadin/ui/GridLayout.java
+++ b/server/src/main/java/com/vaadin/ui/GridLayout.java
@@ -217,16 +217,16 @@ public class GridLayout extends AbstractLayout
// Inserts the component to right place at the list
// Respect top-down, left-right ordering
// component.setParent(this);
- final Iterator<Component> i = components.iterator();
final Map<Connector, ChildComponentData> childDataMap = getState().childData;
int index = 0;
boolean done = false;
- while (!done && i.hasNext()) {
- final ChildComponentData existingArea = childDataMap.get(i.next());
+ for (Component c : components) {
+ final ChildComponentData existingArea = childDataMap.get(c);
if ((existingArea.row1 >= row1 && existingArea.column1 > column1)
|| existingArea.row1 > row1) {
components.add(index, component);
done = true;
+ break;
}
index++;
}
diff --git a/server/src/main/java/com/vaadin/ui/MenuBar.java b/server/src/main/java/com/vaadin/ui/MenuBar.java
index 35988bb84d..f7682408d4 100644
--- a/server/src/main/java/com/vaadin/ui/MenuBar.java
+++ b/server/src/main/java/com/vaadin/ui/MenuBar.java
@@ -20,7 +20,6 @@ import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -169,9 +168,8 @@ public class MenuBar extends AbstractComponent
if (variables.containsKey("clickedId")) {
Integer clickedId = (Integer) variables.get("clickedId");
- Iterator<MenuItem> itr = getItems().iterator();
- while (itr.hasNext()) {
- items.push(itr.next());
+ for (MenuItem i : getItems()) {
+ items.push(i);
}
MenuItem tmpItem = null;
@@ -182,9 +180,8 @@ public class MenuBar extends AbstractComponent
found = (clickedId == tmpItem.getId());
if (tmpItem.hasChildren()) {
- itr = tmpItem.getChildren().iterator();
- while (itr.hasNext()) {
- items.push(itr.next());
+ for (MenuItem i : tmpItem.getChildren()) {
+ items.push(i);
}
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
index 41606737d5..33ca7267ec 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
@@ -109,14 +109,7 @@ public class ColorPickerHistory extends CustomField<Color> {
ArrayBlockingQueue<Color> colorHistory = getColorHistory();
// Check that the color does not already exist
- boolean exists = false;
- Iterator<Color> iter = colorHistory.iterator();
- while (iter.hasNext()) {
- if (color.equals(iter.next())) {
- exists = true;
- break;
- }
- }
+ boolean exists = colorHistory.contains(color);
// If the color does not exist then add it
if (!exists) {
@@ -136,7 +129,7 @@ public class ColorPickerHistory extends CustomField<Color> {
// Create 2d color map
Color[][] colors = new Color[ROWS][COLUMNS];
- iter = colorList.iterator();
+ Iterator<Color> iter = colorList.iterator();
for (int row = 0; row < ROWS; row++) {
for (int col = 0; col < COLUMNS; col++) {
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
index 8d945e9e9c..435f20d64f 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
@@ -18,7 +18,6 @@ package com.vaadin.ui.components.colorpicker;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -761,10 +760,8 @@ public class ColorPickerPopup extends Window implements HasValue<Color> {
.setRequiredIndicatorVisible(isRequiredIndicatorVisible());
}
if (component instanceof HasComponents) {
- Iterator<Component> iterator = ((HasComponents) component)
- .iterator();
- while (iterator.hasNext()) {
- updateColorComponents(iterator.next());
+ for (Component c : (HasComponents) component) {
+ updateColorComponents(c);
}
}
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
index 6953d980f4..485fdcc721 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
@@ -15,7 +15,6 @@
*/
package com.vaadin.ui.components.colorpicker;
-import java.util.Iterator;
import java.util.Objects;
import com.vaadin.data.HasValue;
@@ -220,10 +219,8 @@ public class ColorPickerPreview extends CssLayout implements HasValue<Color> {
((HasValue<?>) component).setReadOnly(isReadOnly());
}
if (component instanceof HasComponents) {
- Iterator<Component> iterator = ((HasComponents) component)
- .iterator();
- while (iterator.hasNext()) {
- updateColorComponents(iterator.next());
+ for (Component c : (HasComponents) component) {
+ updateColorComponents(c);
}
}
}
diff --git a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java
index c42a11e31d..aa37e860d7 100644
--- a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java
@@ -19,7 +19,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.jar.JarEntry;
@@ -119,7 +118,7 @@ public class ClassesSerializableTest {
classes.addAll(findServerClasses(location));
}
- List<Field> nonSerializableFunctionFields = new ArrayList<>();
+ ArrayList<Field> nonSerializableFunctionFields = new ArrayList<>();
List<Class<?>> nonSerializableClasses = new ArrayList<>();
for (String className : classes) {
@@ -221,9 +220,7 @@ public class ClassesSerializableTest {
private void failSerializableClasses(
List<Class<?>> nonSerializableClasses) {
String nonSerializableString = "";
- Iterator<Class<?>> it = nonSerializableClasses.iterator();
- while (it.hasNext()) {
- Class<?> c = it.next();
+ for (Class<?> c : nonSerializableClasses) {
nonSerializableString += ", " + c.getName();
if (c.isAnonymousClass()) {
nonSerializableString += "(super: ";
diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java
index c7f1fbd778..454b5d3b3d 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java
@@ -54,10 +54,7 @@ public class GridDetailsTest {
@Test
public void testGridComponentIteratorContainsDetailsComponents() {
- Iterator<Component> i = grid.iterator();
-
- while (i.hasNext()) {
- Component c = i.next();
+ for (Component c : grid) {
if (c instanceof Label) {
String value = ((Label) c).getValue();
Assert.assertTrue(
diff --git a/server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java b/server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java
index b13a379b05..5f4f3cea65 100644
--- a/server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java
@@ -7,8 +7,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import java.util.Iterator;
-
import org.junit.Before;
import org.junit.Test;
@@ -63,9 +61,8 @@ public class ComponentAttachDetachListenerTest {
attachTarget = event.getContainer();
// Search for component in container (should be found)
- Iterator<Component> iter = attachTarget.iterator();
- while (iter.hasNext()) {
- if (iter.next() == attachedComponent) {
+ for (Component c : attachTarget) {
+ if (c == attachedComponent) {
foundInContainer = true;
break;
}
@@ -93,9 +90,8 @@ public class ComponentAttachDetachListenerTest {
detachedTarget = event.getContainer();
// Search for component in container (should NOT be found)
- Iterator<Component> iter = detachedTarget.iterator();
- while (iter.hasNext()) {
- if (iter.next() == detachedComponent) {
+ for (Component c : detachedTarget) {
+ if (c == detachedComponent) {
foundInContainer = true;
break;
}
diff --git a/uitest/src/main/java/com/vaadin/tests/TestBench.java b/uitest/src/main/java/com/vaadin/tests/TestBench.java
index 388a113768..2c5634ab32 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestBench.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestBench.java
@@ -21,7 +21,6 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -138,9 +137,7 @@ public class TestBench extends com.vaadin.server.LegacyApplication
// try to find a proper test class
// exact match
- Iterator<?> iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
+ for (Object next : menu.getItemIds()) {
if (next instanceof Class) {
Class<?> c = (Class<?>) next;
String string = c.getName();
@@ -153,9 +150,7 @@ public class TestBench extends com.vaadin.server.LegacyApplication
}
// simple name match
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
+ for (Object next : menu.getItemIds()) {
if (next instanceof Class) {
Class<?> c = (Class<?>) next;
String string = c.getSimpleName();
@@ -167,9 +162,7 @@ public class TestBench extends com.vaadin.server.LegacyApplication
}
}
// ticket match
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
+ for (Object next : menu.getItemIds()) {
if (next instanceof Class) {
Class<?> c = (Class<?>) next;
String string = c.getSimpleName();
@@ -183,9 +176,7 @@ public class TestBench extends com.vaadin.server.LegacyApplication
}
// just partly mach lowercase
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
+ for (Object next : menu.getItemIds()) {
if (next instanceof Class) {
Class<?> c = (Class<?>) next;
String string = c.getSimpleName();
@@ -200,9 +191,7 @@ public class TestBench extends com.vaadin.server.LegacyApplication
getMainWindow().showNotification(
"No potential matc for #" + fragment);
-
}
-
}
});
diff --git a/uitest/src/main/java/com/vaadin/tests/components/accordion/RemoveTabs.java b/uitest/src/main/java/com/vaadin/tests/components/accordion/RemoveTabs.java
index 7ca7185500..c86d1b2682 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/accordion/RemoveTabs.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/accordion/RemoveTabs.java
@@ -1,7 +1,6 @@
package com.vaadin.tests.components.accordion;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import com.vaadin.tests.components.TestBase;
@@ -96,11 +95,9 @@ public class RemoveTabs extends TestBase {
}
private void closeLastTab() {
- Iterator<Component> i = accordion.iterator();
Component last = null;
- while (i.hasNext()) {
- last = i.next();
-
+ for (Component c : accordion) {
+ last = c;
}
accordion.removeComponent(last);
}
@@ -110,9 +107,7 @@ public class RemoveTabs extends TestBase {
if (container != null) {
List<Component> c = new ArrayList<>();
- Iterator<Component> i = container.iterator();
- while (i.hasNext()) {
- Component comp = i.next();
+ for (Component comp : container) {
c.add(comp);
}
container.removeAllComponents();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/composite/CompositeChainUI.java b/uitest/src/main/java/com/vaadin/tests/components/composite/CompositeChainUI.java
index 481f7c958f..bfb3bf0bfc 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/composite/CompositeChainUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/composite/CompositeChainUI.java
@@ -82,10 +82,9 @@ public class CompositeChainUI extends AbstractTestUIWithLog {
String msg = component.getClass().getSimpleName();
if (component instanceof HasComponents) {
- Iterator<Component> iterator = ((HasComponents) component)
- .iterator();
- if (iterator.hasNext()) {
- Component content = iterator.next();
+ Iterator<Component> it = ((HasComponents) component).iterator();
+ if (it.hasNext()) {
+ Component content = it.next();
if (content != null) {
msg += " -> " + getHierarchy(content);
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java
index 3dd2d0cd0a..4a04ff669c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java
@@ -1,7 +1,6 @@
package com.vaadin.tests.components.tabsheet;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import com.vaadin.tests.components.TestBase;
@@ -120,11 +119,9 @@ public class RemoveTabs extends TestBase {
}
private void closeLastTab() {
- Iterator<Component> i = tabsheet.getComponentIterator();
Component last = null;
- while (i.hasNext()) {
- last = i.next();
-
+ for (Component c : tabsheet) {
+ last = c;
}
tabsheet.removeComponent(last);
}
@@ -134,9 +131,7 @@ public class RemoveTabs extends TestBase {
if (container != null) {
List<Component> c = new ArrayList<>();
- Iterator<Component> i = container.getComponentIterator();
- while (i.hasNext()) {
- Component comp = i.next();
+ for (Component comp : container) {
c.add(comp);
}
container.removeAllComponents();
diff --git a/uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java b/uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java
index b808a3d973..bdc021868d 100644
--- a/uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java
+++ b/uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java
@@ -1,7 +1,5 @@
package com.vaadin.tests.urifragments;
-import java.util.Iterator;
-
import com.vaadin.server.Page;
import com.vaadin.server.Page.UriFragmentChangedEvent;
import com.vaadin.server.Page.UriFragmentChangedListener;
@@ -62,12 +60,10 @@ public class FragmentHandlingAndAsynchUIUpdate extends AbstractTestUIWithLog {
return;
}
- Iterator<Component> it = getLayout().iterator();
final String frag = event.getUriFragment().substring(4);
Component fragComp = null;
- while (it.hasNext()) {
- Component comp = it.next();
+ for (Component comp : getLayout()) {
if (comp.getId() != null && comp instanceof Label
&& comp.getId().equals(frag)) {
fragComp = comp;