- Timestamp:
- 2021-02-20T20:52:51+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r17011 r17497 106 106 * @param p OSM primitive 107 107 * @param matchingSelector matching selector 108 * @return fix command 108 * @return fix command, or {@code null} if if cannot be created 109 109 */ 110 110 Command createCommand(OsmPrimitive p, Selector matchingSelector); … … 182 182 183 183 /** 184 * Creates a fixing command which executes a {@link ChangePropertyKeyCommand} on the specified keys. 184 * Creates a fixing command which executes a {@link ChangePropertyKeyCommand} on the specified keys 185 * if {@code p} does not already have {@code newKey} 185 186 * @param oldKey old key 186 187 * @param newKey new key 187 * @return created fix command 188 * @return created fix command, or {@code null} 188 189 */ 189 190 static FixCommand fixChangeKey(final String oldKey, final String newKey) { … … 191 192 @Override 192 193 public Command createCommand(OsmPrimitive p, Selector matchingSelector) { 193 return new ChangePropertyKeyCommand(p,194 return p.hasKey(newKey) ? null : new ChangePropertyKeyCommand(p, 194 195 TagCheck.insertArguments(matchingSelector, oldKey, p), 195 196 TagCheck.insertArguments(matchingSelector, newKey, p)); … … 465 466 Collection<Command> cmds = fixCommands.stream() 466 467 .map(fixCommand -> fixCommand.createCommand(p, matchingSelector)) 468 .filter(Objects::nonNull) 467 469 .collect(Collectors.toList()); 468 470 if (deletion && !p.isDeleted()) { 469 471 cmds.add(new DeleteCommand(p)); 470 472 } 471 return new SequenceCommand(tr("Fix of {0}", getDescriptionForMatchingSelector(p, matchingSelector)), cmds); 473 return cmds.isEmpty() ? null 474 : new SequenceCommand(tr("Fix of {0}", getDescriptionForMatchingSelector(p, matchingSelector)), cmds); 472 475 } catch (IllegalArgumentException e) { 473 476 Logging.error(e);
Note:
See TracChangeset
for help on using the changeset viewer.