Changeset 16622 in josm for trunk/src/org


Ignore:
Timestamp:
2020-06-14T14:55:14+02:00 (4 years ago)
Author:
simon04
Message:

see #19334 - https://errorprone.info/bugpattern/UnnecessaryLambda

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r16426 r16622  
    2929import java.util.TreeMap;
    3030import java.util.concurrent.TimeUnit;
    31 import java.util.function.Predicate;
    3231import java.util.stream.Collectors;
    3332import java.util.stream.Stream;
     
    184183    protected final SortedMap<String, Setting<?>> defaultsMap = new TreeMap<>();
    185184
    186     private final Predicate<Entry<String, Setting<?>>> NO_DEFAULT_SETTINGS_ENTRY =
    187             e -> !e.getValue().equals(defaultsMap.get(e.getKey()));
    188 
    189185    /**
    190186     * Indicates whether {@link #init(boolean)} completed successfully.
     
    420416     */
    421417    public synchronized void save() throws IOException {
    422         save(getPreferenceFile(), settingsMap.entrySet().stream().filter(NO_DEFAULT_SETTINGS_ENTRY), false);
     418        save(getPreferenceFile(), settingsMap.entrySet().stream().filter(e -> !e.getValue().equals(defaultsMap.get(e.getKey()))), false);
    423419    }
    424420
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r16592 r16622  
    1616import java.util.Map.Entry;
    1717import java.util.Objects;
    18 import java.util.function.Predicate;
    1918
    2019import javax.swing.JOptionPane;
     
    4241public final class HistoryBrowserDialogManager implements LayerChangeListener {
    4342
    44     static final class UnloadedHistoryPredicate implements Predicate<PrimitiveId> {
    45         private final HistoryDataSet hds = HistoryDataSet.getInstance();
    46 
    47         @Override
    48         public boolean test(PrimitiveId p) {
    49             History h = hds.getHistory(p);
    50             if (h == null)
    51                 // reload if the history is not in the cache yet
    52                 return true;
    53             else
    54                 // reload if the history object of the selected object is not in the cache yet
    55                 return !p.isNew() && h.getByVersion(p.getUniqueId()) == null;
    56         }
     43    private static boolean isUnloaded(PrimitiveId p) {
     44        History h = HistoryDataSet.getInstance().getHistory(p);
     45        if (h == null)
     46            // reload if the history is not in the cache yet
     47            return true;
     48        else
     49            // reload if the history object of the selected object is not in the cache yet
     50            return !p.isNew() && h.getByVersion(p.getUniqueId()) == null;
    5751    }
    5852
     
    6256
    6357    private final LinkedHashMap<Long, HistoryBrowserDialog> dialogs = new LinkedHashMap<>();
    64 
    65     private final Predicate<PrimitiveId> unloadedHistoryPredicate = new UnloadedHistoryPredicate();
    66 
    67     private final Predicate<PrimitiveId> notNewPredicate = p -> !p.isNew();
    6858
    6959    private static final List<HistoryHook> hooks = new ArrayList<>();
     
    217207        final List<PrimitiveId> realPrimitives = new ArrayList<>(primitives);
    218208        hooks.forEach(h -> h.modifyRequestedIds(realPrimitives));
    219         final Collection<? extends PrimitiveId> notNewPrimitives = SubclassFilteredCollection.filter(realPrimitives, notNewPredicate);
     209        final Collection<? extends PrimitiveId> notNewPrimitives = SubclassFilteredCollection.filter(realPrimitives, p1 -> !p1.isNew());
    220210        if (notNewPrimitives.isEmpty()) {
    221211            JOptionPane.showMessageDialog(
     
    237227        }
    238228
    239         Collection<? extends PrimitiveId> toLoad = SubclassFilteredCollection.filter(notNewPrimitives, unloadedHistoryPredicate);
     229        Collection<? extends PrimitiveId> toLoad = SubclassFilteredCollection.filter(notNewPrimitives, HistoryBrowserDialogManager::isUnloaded);
    240230        if (!toLoad.isEmpty()) {
    241231            MainApplication.worker.submit(new HistoryLoadTask(parent).addPrimitiveIds(toLoad));
Note: See TracChangeset for help on using the changeset viewer.