Ignore:
Timestamp:
2020-01-05T21:09:21+01:00 (4 years ago)
Author:
Don-vip
Message:

fix #18455 - detect objects not matching their presets object type (info level)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r15029 r15640  
    2323import java.util.concurrent.CompletableFuture;
    2424import java.util.function.Predicate;
     25import java.util.stream.Collectors;
    2526
    2627import javax.swing.AbstractAction;
     
    525526    public Collection<OsmPrimitive> createSelection(Collection<OsmPrimitive> participants) {
    526527        originalSelectionEmpty = participants.isEmpty();
    527         Collection<OsmPrimitive> sel = new LinkedList<>();
    528         for (OsmPrimitive osm : participants) {
    529             if (typeMatches(EnumSet.of(TaggingPresetType.forPrimitive(osm)))) {
    530                 sel.add(osm);
    531             }
    532         }
    533         return sel;
     528        return participants.stream().filter(this::typeMatches).collect(Collectors.toList());
    534529    }
    535530
     
    540535    public List<Tag> getChangedTags() {
    541536        List<Tag> result = new ArrayList<>();
    542         for (TaggingPresetItem i: data) {
    543             i.addCommands(result);
    544         }
     537        data.forEach(i -> i.addCommands(result));
    545538        return result;
    546539    }
     
    585578    public String toString() {
    586579        return (types == null ? "" : types.toString()) + ' ' + name;
     580    }
     581
     582    /**
     583     * Determines whether this preset matches the OSM primitive type.
     584     * @param primitive The OSM primitive for which type must match
     585     * @return <code>true</code> if type matches.
     586     * @since 15640
     587     */
     588    public final boolean typeMatches(IPrimitive primitive) {
     589        return typeMatches(EnumSet.of(TaggingPresetType.forPrimitive(primitive)));
    587590    }
    588591
Note: See TracChangeset for help on using the changeset viewer.