Ignore:
Timestamp:
2020-05-17T14:18:22+02:00 (4 years ago)
Author:
simon04
Message:

see #19251 - Java 8: use Stream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r15716 r16438  
    2323import java.util.Set;
    2424import java.util.regex.Pattern;
     25import java.util.stream.Collectors;
     26import java.util.stream.IntStream;
    2527
    2628import javax.swing.AbstractAction;
     
    331333                    return requiresRestart;
    332334            }
    333             for (PluginInformation pi : model.getNewlyActivatedPlugins()) {
    334                 if (!pi.canloadatruntime)
    335                     return true;
    336             }
     335            return model.getNewlyActivatedPlugins().stream().anyMatch(pi -> !pi.canloadatruntime);
    337336        }
    338337        return false;
     
    436435                if (pluginDownloadTask.isCanceled())
    437436                    return;
    438                 boolean restartRequired = false;
    439                 for (PluginInformation pi : pluginDownloadTask.getDownloadedPlugins()) {
    440                     if (!model.getNewlyActivatedPlugins().contains(pi) || !pi.canloadatruntime) {
    441                         restartRequired = true;
    442                         break;
    443                     }
    444                 }
     437                boolean restartRequired = pluginDownloadTask.getDownloadedPlugins().stream()
     438                        .anyMatch(pi -> !(model.getNewlyActivatedPlugins().contains(pi) && pi.canloadatruntime));
    445439                notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask, restartRequired);
    446440                model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins());
     
    638632            if (model.getSize() == 0)
    639633                return Collections.emptyList();
    640             List<String> ret = new ArrayList<>(model.getSize());
    641             for (int i = 0; i < model.getSize(); i++) {
    642                 ret.add(model.get(i));
    643             }
    644             return ret;
     634            return IntStream.range(0, model.getSize())
     635                    .mapToObj(model::get)
     636                    .collect(Collectors.toList());
    645637        }
    646638    }
Note: See TracChangeset for help on using the changeset viewer.