diff options
19 files changed, 51 insertions, 86 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java index d92a17f4b8..e978a08119 100644 --- a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java +++ b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java @@ -339,9 +339,7 @@ public class VCustomLayout extends ComplexPanel { /** Get the location of an widget */ public String getLocation(Widget w) { - for (final Iterator<String> i = locationToWidget.keySet().iterator(); i - .hasNext();) { - final String location = i.next(); + for (final String location : locationToWidget.keySet()) { if (locationToWidget.get(location) == w) { return location; } diff --git a/client/src/main/java/com/vaadin/client/ui/VNotification.java b/client/src/main/java/com/vaadin/client/ui/VNotification.java index f5815e093b..e5358a3db7 100644 --- a/client/src/main/java/com/vaadin/client/ui/VNotification.java +++ b/client/src/main/java/com/vaadin/client/ui/VNotification.java @@ -466,17 +466,14 @@ public class VNotification extends VOverlay { } public void removeEventListener(EventListener listener) { - if (listeners == null) { - return; + if (listeners != null) { + listeners.remove(listener); } - listeners.remove(listener); } private void fireEvent(HideEvent event) { if (listeners != null) { - for (Iterator<EventListener> it = listeners.iterator(); it - .hasNext();) { - EventListener l = it.next(); + for (EventListener l : listeners) { l.notificationHidden(event); } } diff --git a/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetBaseConnector.java b/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetBaseConnector.java index 1bd721787c..5d49c6cbce 100644 --- a/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetBaseConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetBaseConnector.java @@ -96,9 +96,7 @@ public abstract class TabsheetBaseConnector } // Detach any old tab widget, should be max 1 - for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator - .hasNext();) { - Widget oldWidget = iterator.next(); + for (Widget oldWidget : oldWidgets) { if (oldWidget.isAttached()) { oldWidget.removeFromParent(); } 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 96942dd803..38bb1943cf 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 @@ -4031,9 +4031,8 @@ public class VScrollTable extends FlowPanel for (i = 0; i < visibleColOrder.length; i++) { cols[i] = visibleColOrder[i]; } - for (final Iterator<String> it = collapsedColumns.iterator(); it - .hasNext();) { - cols[i++] = it.next(); + for (final String column : collapsedColumns) { + cols[i++] = column; } } List<Action> actions = new ArrayList<Action>(cols.length); @@ -4401,11 +4400,11 @@ public class VScrollTable extends FlowPanel .getOffsetWidth() + getHeaderPadding(); if (columnIndex < 0) { columnIndex = 0; - for (Iterator<Widget> it = tHead.iterator(); it - .hasNext(); columnIndex++) { - if (it.next() == this) { + for (Widget widget : tHead) { + if (widget == this) { break; } + columnIndex++; } } final int cw = scrollBody.getColWidth(columnIndex); @@ -6441,14 +6440,10 @@ public class VScrollTable extends FlowPanel // Hide rows which are not selected Element dragImage = ev.getDragImage(); int i = 0; - for (Iterator<Widget> iterator = scrollBody - .iterator(); iterator.hasNext();) { - VScrollTableRow next = (VScrollTableRow) iterator - .next(); - + for (Widget next : scrollBody) { Element child = (Element) dragImage.getChild(i++); - if (!rowKeyIsSelected(next.rowKey)) { + if (!rowKeyIsSelected(((VScrollTableRow) next).rowKey)) { child.getStyle().setVisibility(Visibility.HIDDEN); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/VaadinClasses.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/VaadinClasses.java index fd2ae40cb5..f8667dda6f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/VaadinClasses.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/VaadinClasses.java @@ -19,7 +19,7 @@ public class VaadinClasses { private static final Set<String> WHITE_LIST_FQNS = new HashSet<String>(); - public static List<Class<? extends Field>> getFields() { + public static List<Class<? extends Field<?>>> getFields() { return getServerClasses(Field.class::isAssignableFrom) .map(VaadinClasses::castFieldClass) .collect(Collectors.toList()); @@ -50,8 +50,8 @@ public class VaadinClasses { .collect(Collectors.toList()); } - private static Class<? extends Field> castFieldClass(Class<?> clazz) { - return (Class<? extends Field>) clazz; + private static Class<? extends Field<?>> castFieldClass(Class<?> clazz) { + return (Class<? extends Field<?>>) clazz; } private static Class<? extends Component> castComponentClass( diff --git a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java index 19ece940e2..9e1134efed 100644 --- a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java +++ b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java @@ -92,9 +92,7 @@ public class ComponentSizeValidator implements Serializable { } } else if (isForm(component)) { HasComponents form = (HasComponents) component; - for (Iterator<Component> iterator = form.iterator(); iterator - .hasNext();) { - Component child = iterator.next(); + for (Component child : form) { errors = validateComponentRelativeSizes(child, errors, parent); } } @@ -129,7 +127,7 @@ public class ComponentSizeValidator implements Serializable { StringBuffer err = new StringBuffer(); err.append("Vaadin DEBUG\n"); - StringBuilder indent = new StringBuilder(""); + StringBuilder indent = new StringBuilder(); ComponentInfo ci; if (attributes != null) { while (attributes.size() > LAYERS_SHOWN) { diff --git a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java index f7669ef135..a2df4203c8 100644 --- a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java +++ b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java @@ -224,7 +224,7 @@ public class JsonPaintTarget implements PaintTarget { */ static StringBuilder escapeXML(StringBuilder xml) { if (xml == null || xml.length() <= 0) { - return new StringBuilder(""); + return new StringBuilder(); } final StringBuilder result = new StringBuilder(xml.length() * 2); diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java index 27029f20de..4c6e49cd24 100644 --- a/server/src/main/java/com/vaadin/ui/Upload.java +++ b/server/src/main/java/com/vaadin/ui/Upload.java @@ -841,9 +841,7 @@ public class Upload extends AbstractComponent // 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/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java b/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java index c4fe9a2a65..6baa1b364b 100644 --- a/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java +++ b/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java @@ -89,10 +89,8 @@ public class ListenerOrder extends com.vaadin.server.LegacyApplication s1.addListener((ValueChangeListener) this); Item i = s1.getItem("second"); - for (Iterator<?> it = i.getItemPropertyIds().iterator(); it - .hasNext();) { - Object o = it.next(); - System.out.println("[" + o + "]"); + for (Object id : i.getItemPropertyIds()) { + System.out.println("[" + id + "]"); } } diff --git a/uitest/src/main/java/com/vaadin/tests/Parameters.java b/uitest/src/main/java/com/vaadin/tests/Parameters.java index d59c717b75..bb38110bcc 100644 --- a/uitest/src/main/java/com/vaadin/tests/Parameters.java +++ b/uitest/src/main/java/com/vaadin/tests/Parameters.java @@ -114,10 +114,9 @@ public class Parameters extends com.vaadin.server.LegacyApplication params.removeAllItems(); Map<String, String[]> parameters = request.getParameterMap(); - for (final Iterator<String> i = parameters.keySet().iterator(); i - .hasNext();) { - final String name = i.next(); - final String[] values = parameters.get(name); + for (final Map.Entry<String, String[]> entry : parameters.entrySet()) { + final String name = entry.getKey(); + final String[] values = entry.getValue(); String v = ""; for (int j = 0; j < values.length; j++) { if (v.length() > 0) { diff --git a/uitest/src/main/java/com/vaadin/tests/TestBench.java b/uitest/src/main/java/com/vaadin/tests/TestBench.java index d66f58e539..076d02b4be 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestBench.java +++ b/uitest/src/main/java/com/vaadin/tests/TestBench.java @@ -20,9 +20,10 @@ import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; -import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import com.vaadin.server.ExternalResource; import com.vaadin.server.LegacyApplication; @@ -69,8 +70,7 @@ public class TestBench extends com.vaadin.server.LegacyApplication VerticalLayout bodyLayout = new VerticalLayout(); - // TODO this could probably be a simple Set - HashMap<Class<?>, String> itemCaptions = new HashMap<>(); + Set<Class<?>> itemCaptions = new HashSet<>(); @Override public void init() { @@ -81,23 +81,21 @@ public class TestBench extends com.vaadin.server.LegacyApplication try { final List<Class<?>> testableClasses = getTestableClassesForPackage( testablePackages[p]); - for (final Iterator<Class<?>> it = testableClasses - .iterator(); it.hasNext();) { - final Class<?> t = it.next(); + for (final Class<?> t : testableClasses) { // ignore TestBench itself if (t.equals(TestBench.class)) { continue; } try { testables.addItem(t); - itemCaptions.put(t, t.getName()); + itemCaptions.add(t); testables.setParent(t, testablePackages[p]); testables.setChildrenAllowed(t, false); continue; } catch (final Exception e) { try { testables.addItem(t); - itemCaptions.put(t, t.getName()); + itemCaptions.add(t); testables.setParent(t, testablePackages[p]); testables.setChildrenAllowed(t, false); continue; @@ -113,18 +111,15 @@ public class TestBench extends com.vaadin.server.LegacyApplication menu = new Tree("Testables", testables); - for (final Iterator<Class<?>> i = itemCaptions.keySet().iterator(); i - .hasNext();) { - final Class<?> testable = i.next(); + for (final Class<?> testable : itemCaptions) { // simplify captions final String name = testable.getName() .substring(testable.getName().lastIndexOf('.') + 1); menu.setItemCaption(testable, name); } // expand all root items - for (final Iterator<?> i = menu.rootItemIds().iterator(); i - .hasNext();) { - menu.expandItemsRecursively(i.next()); + for (final Object id : menu.rootItemIds()) { + menu.expandItemsRecursively(id); } menu.addListener(this); @@ -302,8 +297,7 @@ public class TestBench extends com.vaadin.server.LegacyApplication final ArrayList<Class<?>> classes = new ArrayList<>(); // For every directory identified capture all the .class files - for (final Iterator<File> it = directories.iterator(); it.hasNext();) { - final File directory = it.next(); + for (final File directory : directories) { if (directory.exists()) { // Get the list of the files contained in the package final String[] files = directory.list(); diff --git a/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java b/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java index b7c4885c17..b4b933ecde 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java @@ -77,6 +77,7 @@ public class TestForMultipleStyleNames extends CustomComponent } + @SuppressWarnings("unchecked") @Override public void valueChange(ValueChangeEvent event) { @@ -89,11 +90,9 @@ public class TestForMultipleStyleNames extends CustomComponent } } - final Collection<?> styles = (Collection<?>) s.getValue(); + final Collection<String> styles = (Collection<String>) s.getValue(); - for (final Iterator<?> iterator = styles.iterator(); iterator - .hasNext();) { - final String styleName = (String) iterator.next(); + for (final String styleName : styles) { if (curStyles.contains(styleName)) { // already added curStyles.remove(styleName); @@ -101,9 +100,7 @@ public class TestForMultipleStyleNames extends CustomComponent l.addStyleName(styleName); } } - for (final Iterator<String> iterator2 = curStyles.iterator(); iterator2 - .hasNext();) { - final String object = iterator2.next(); + for (final String object : curStyles) { l.removeStyleName(object); } } diff --git a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java index 584a952885..40e7f82014 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java +++ b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java @@ -303,9 +303,7 @@ public class TestSizeableIncomponents extends LegacyApplication { ((Label) c).setValue("Test label"); } - for (Iterator<Configuration> i = configurations.iterator(); i - .hasNext();) { - Configuration conf = i.next(); + for (Configuration conf : configurations) { conf.configure(c); } return c; diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableTest.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableTest.java index e8903ed92f..c6e4749a98 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableTest.java @@ -65,8 +65,7 @@ public class TreeTableTest extends Tables<TreeTable> Hierarchical c = getComponent().getContainerDataSource(); int idx = 0; - for (Iterator<?> i = c.getItemIds().iterator(); i.hasNext();) { - Object id = i.next(); + for (Object id : c.getItemIds()) { if (id == itemId) { if (idx % 2 == 1) { return "bold"; diff --git a/uitest/src/main/java/com/vaadin/tests/dd/TreeDragStart.java b/uitest/src/main/java/com/vaadin/tests/dd/TreeDragStart.java index 3c21c90475..0709e5d888 100644 --- a/uitest/src/main/java/com/vaadin/tests/dd/TreeDragStart.java +++ b/uitest/src/main/java/com/vaadin/tests/dd/TreeDragStart.java @@ -57,8 +57,8 @@ public class TreeDragStart extends TestBase { getLayout().addComponent(tree); // Expand all items - for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) { - tree.expandItemsRecursively(it.next()); + for (Object id : tree.rootItemIds()) { + tree.expandItemsRecursively(id); } // Set the tree in drag source mode diff --git a/uitest/src/main/java/com/vaadin/tests/integration/JSR286Portlet.java b/uitest/src/main/java/com/vaadin/tests/integration/JSR286Portlet.java index 5abb63cb63..b06fb68ef8 100644 --- a/uitest/src/main/java/com/vaadin/tests/integration/JSR286Portlet.java +++ b/uitest/src/main/java/com/vaadin/tests/integration/JSR286Portlet.java @@ -147,9 +147,9 @@ public class JSR286Portlet extends UI { .getAttribute(PortletRequest.USER_INFO); if (uinfo != null) { String s = ""; - for (Iterator<?> it = uinfo.keySet().iterator(); it.hasNext();) { - Object key = it.next(); - Object val = uinfo.get(key); + for (Map.Entry<?, ?> entry : uinfo.entrySet()) { + Object key = entry.getKey(); + Object val = entry.getValue(); s += key + ": " + val + "\n"; } if (request.isUserInRole("administrator")) { diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/ValoThemeUI.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/ValoThemeUI.java index 1268a5cbde..4ec83dc6ec 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/ValoThemeUI.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/ValoThemeUI.java @@ -146,15 +146,12 @@ public class ValoThemeUI extends UI { @Override public void afterViewChange(ViewChangeEvent event) { - for (Iterator<Component> it = menuItemsLayout.iterator(); it - .hasNext();) { - it.next().removeStyleName("selected"); + for (Component c : menuItemsLayout) { + c.removeStyleName("selected"); } for (Entry<String, String> item : menuItems.entrySet()) { if (event.getViewName().equals(item.getKey())) { - for (Iterator<Component> it = menuItemsLayout - .iterator(); it.hasNext();) { - Component c = it.next(); + for (Component c : menuItemsLayout) { if (c.getCaption() != null && c.getCaption() .startsWith(item.getValue())) { c.addStyleName("selected"); 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 cb948b789e..1606a40272 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 @@ -35,8 +35,8 @@ public class TreeHorizontalResize extends TestBase { Tree tree = new Tree(); tree.setContainerDataSource(getHardwareContainer()); tree.setItemCaptionPropertyId(hw_PROPERTY_NAME); - for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) { - tree.expandItemsRecursively(it.next()); + for (Object id : tree.rootItemIds()) { + tree.expandItemsRecursively(id); } treeLayout.addComponent(tree); } diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/Trees.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/Trees.java index b53c125be3..17e63bea4a 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/Trees.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/Trees.java @@ -57,8 +57,7 @@ public class Trees extends AbstractSelectTestCase<Tree> .getContainerDataSource(); int idx = 0; - for (Iterator<?> i = c.getItemIds().iterator(); i.hasNext();) { - Object id = i.next(); + for (Object id : c.getItemIds()) { if (id == itemId) { if (idx % 2 == 1) { return "bold"; |