Changeset 19294 in josm
- Timestamp:
- 2025-01-28T12:28:11+01:00 (37 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java
r19214 r19294 25 25 public class AddPrimitivesCommand extends Command { 26 26 27 private List<PrimitiveData> data;27 private List<PrimitiveData> primitiveData; 28 28 private Collection<PrimitiveData> toSelect; 29 29 private List<PrimitiveData> preExistingData; … … 56 56 private void init(List<PrimitiveData> data, List<PrimitiveData> toSelect) { 57 57 CheckParameterUtil.ensureParameterNotNull(data, "data"); 58 this. data = new ArrayList<>(data);58 this.primitiveData = new ArrayList<>(data); 59 59 if (toSelect == data) { 60 this.toSelect = this. data;60 this.toSelect = this.primitiveData; 61 61 } else if (toSelect != null) { 62 62 this.toSelect = new ArrayList<>(toSelect); … … 76 76 private void executeRealCommand(DataSet ds) { 77 77 if (createdPrimitives == null) { // first time execution 78 List<OsmPrimitive> newPrimitives = new ArrayList<>( data.size());78 List<OsmPrimitive> newPrimitives = new ArrayList<>(primitiveData.size()); 79 79 preExistingData = new ArrayList<>(); 80 80 81 for (PrimitiveData pd : data) {81 for (PrimitiveData pd : primitiveData) { 82 82 OsmPrimitive primitive = ds.getPrimitiveById(pd); 83 83 boolean created = primitive == null; … … 99 99 for (int i = 0; i < newPrimitives.size(); i++) { 100 100 if (!(newPrimitives.get(i) instanceof Node)) { 101 newPrimitives.get(i).load( data.get(i));101 newPrimitives.get(i).load(primitiveData.get(i)); 102 102 } 103 103 } … … 108 108 for (OsmPrimitive osm : createdPrimitives) { 109 109 if (preExistingData.stream().anyMatch(pd -> pd.getPrimitiveId().equals(osm.getPrimitiveId()))) { 110 Optional<PrimitiveData> o = data.stream()110 Optional<PrimitiveData> o = primitiveData.stream() 111 111 .filter(pd -> pd.getPrimitiveId().equals(osm.getPrimitiveId())).findAny(); 112 112 o.ifPresent(osm::load); … … 121 121 DataSet ds = getAffectedDataSet(); 122 122 if (createdPrimitives == null) { 123 createdPrimitives = new ArrayList<>( data.size());124 for (PrimitiveData pd : data) {123 createdPrimitives = new ArrayList<>(primitiveData.size()); 124 for (PrimitiveData pd : primitiveData) { 125 125 OsmPrimitive p = ds.getPrimitiveById(pd); 126 126 createdPrimitives.add(p); … … 147 147 @Override 148 148 public String getDescriptionText() { 149 int size = data != null ?data.size() : createdPrimitives.size();149 int size = primitiveData != null ? primitiveData.size() : createdPrimitives.size(); 150 150 return trn("Added {0} object", "Added {0} objects", size, size); 151 151 } … … 162 162 return createdPrimitives; 163 163 164 return data.stream()164 return primitiveData.stream() 165 165 .map(d -> Objects.requireNonNull(getAffectedDataSet().getPrimitiveById(d), () -> "No primitive found for " + d)) 166 166 .collect(Collectors.toSet()); … … 169 169 @Override 170 170 public int hashCode() { 171 return Objects.hash(super.hashCode(), data, toSelect, preExistingData, createdPrimitives);171 return Objects.hash(super.hashCode(), primitiveData, toSelect, preExistingData, createdPrimitives); 172 172 } 173 173 … … 178 178 if (!super.equals(obj)) return false; 179 179 AddPrimitivesCommand that = (AddPrimitivesCommand) obj; 180 return Objects.equals( data, that.data) &&180 return Objects.equals(primitiveData, that.primitiveData) && 181 181 Objects.equals(toSelect, that.toSelect) && 182 182 Objects.equals(preExistingData, that.preExistingData) &&
Note:
See TracChangeset
for help on using the changeset viewer.