diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-09-29 14:14:05 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-09-29 15:14:05 +0300 |
commit | adcf2e2e80c6a05ea5e43be15dc7a2576fd2bbb4 (patch) | |
tree | 0a58b0b09cb371f757d74f83ad872f2113f96272 /uitest/src/main | |
parent | 46950473fdb3cfb9d44660b3a642a9229cecded2 (diff) | |
download | vaadin-framework-adcf2e2e80c6a05ea5e43be15dc7a2576fd2bbb4.tar.gz vaadin-framework-adcf2e2e80c6a05ea5e43be15dc7a2576fd2bbb4.zip |
Use enhanced for loop instead of Iterator. (#10100)
Diffstat (limited to 'uitest/src/main')
5 files changed, 14 insertions, 40 deletions
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; |