Changeset 15667 in josm for trunk/src/org
- Timestamp:
- 2020-01-09T23:42:30+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r15645 r15667 23 23 import java.util.Set; 24 24 import java.util.regex.Pattern; 25 import java.util.stream.Collectors; 25 26 26 27 import javax.swing.JCheckBox; … … 35 36 import org.openstreetmap.josm.data.osm.OsmPrimitive; 36 37 import org.openstreetmap.josm.data.osm.Tag; 38 import org.openstreetmap.josm.data.osm.TagMap; 37 39 import org.openstreetmap.josm.data.osm.Tagged; 38 40 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; … … 615 617 616 618 if (checkPresetsTypes) { 617 for (TaggingPreset tp : TaggingPresets.getMatchingPresets(null, p.getKeys(), false)) { 618 TaggingPresetType presetType = TaggingPresetType.forPrimitive(p); 619 if (!tp.typeMatches(EnumSet.of(presetType))) { 619 TagMap tags = p.getKeys(); 620 TaggingPresetType presetType = TaggingPresetType.forPrimitive(p); 621 EnumSet<TaggingPresetType> presetTypes = EnumSet.of(presetType); 622 Collection<TaggingPreset> matchingPresets = TaggingPresets.getMatchingPresets(null, tags, false); 623 Collection<TaggingPreset> matchingPresetsOK = matchingPresets.stream().filter( 624 tp -> tp.typeMatches(presetTypes)).collect(Collectors.toList()); 625 Collection<TaggingPreset> matchingPresetsKO = matchingPresets.stream().filter( 626 tp -> !tp.typeMatches(presetTypes)).collect(Collectors.toList()); 627 628 for (TaggingPreset tp : matchingPresetsKO) { 629 // Potential error, unless matching tags are all known by a supported preset 630 Map<String, String> matchingTags = tp.data.stream() 631 .filter(i -> Boolean.TRUE.equals(i.matches(tags))) 632 .filter(i -> i instanceof KeyedItem).map(i -> ((KeyedItem) i).key) 633 .collect(Collectors.toMap(k -> k, tags::get)); 634 if (matchingPresetsOK.stream().noneMatch( 635 tp2 -> matchingTags.entrySet().stream().allMatch( 636 e -> tp2.data.stream().anyMatch( 637 i -> i instanceof KeyedItem && ((KeyedItem) i).key.equals(e.getKey()))))) { 620 638 errors.add(TestError.builder(this, Severity.OTHER, INVALID_PRESETS_TYPE) 621 639 .message(tr("Object type not in preset"), -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java
r15293 r15667 76 76 * @return {@code true} if matches (positive), {@code null} if neutral, {@code false} if mismatches (negative). 77 77 */ 78 p rotectedBoolean matches(Map<String, String> tags) {78 public Boolean matches(Map<String, String> tags) { 79 79 return null; 80 80 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/CheckGroup.java
r9665 r15667 53 53 54 54 @Override 55 p rotectedBoolean matches(Map<String, String> tags) {55 public Boolean matches(Map<String, String> tags) { 56 56 for (Check check : checks) { 57 57 if (Boolean.TRUE.equals(check.matches(tags))) { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java
r14706 r15667 191 191 192 192 @Override 193 p rotectedBoolean matches(Map<String, String> tags) {193 public Boolean matches(Map<String, String> tags) { 194 194 switch (MatchType.ofString(match)) { 195 195 case NONE:
Note:
See TracChangeset
for help on using the changeset viewer.