001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.command; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.util.List; 007 008import org.openstreetmap.josm.data.osm.DataSet; 009import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 010import org.openstreetmap.josm.data.osm.Node; 011import org.openstreetmap.josm.data.osm.Way; 012 013/** 014 * Command that changes the nodes list of a way. 015 * The same can be done with ChangeCommand, but this is more 016 * efficient. (Needed for the duplicate node fixing 017 * tool of the validator, when processing large data sets.) 018 * 019 * @author Imi 020 */ 021public class ChangeNodesCommand extends AbstractNodesCommand<List<Node>> { 022 023 /** 024 * Constructs a new {@code ChangeNodesCommand}. 025 * @param way The way to modify 026 * @param newNodes The new list of nodes for the given way 027 */ 028 public ChangeNodesCommand(Way way, List<Node> newNodes) { 029 super(way.getDataSet(), way, newNodes); 030 } 031 032 /** 033 * Constructs a new {@code ChangeNodesCommand}. 034 * @param ds The target data set. Must not be {@code null} 035 * @param way The way to modify 036 * @param newNodes The new list of nodes for the given way 037 * @since 12726 038 */ 039 public ChangeNodesCommand(DataSet ds, Way way, List<Node> newNodes) { 040 super(ds, way, newNodes); 041 } 042 043 @Override 044 public void modifyWay() { 045 way.setNodes(cmdNodes); 046 } 047 048 @Override 049 public String getDescriptionText() { 050 return tr("Change nodes of {0}", way.getDisplayName(DefaultNameFormatter.getInstance())); 051 } 052}