diff options
Diffstat (limited to 'compatibility-server')
19 files changed, 100 insertions, 180 deletions
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); |