Skip to content

Commit 414b152

Browse files
committed
fix: cleanup
1 parent 35273cb commit 414b152

File tree

2 files changed

+9
-38
lines changed

2 files changed

+9
-38
lines changed

backend/src/main/java/ch/xxx/maps/domain/model/dto/Tuple.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

backend/src/main/java/ch/xxx/maps/usecase/mapper/EntityDtoMapper.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import ch.xxx.maps.domain.model.dto.LocationDto;
2424
import ch.xxx.maps.domain.model.dto.PolygonDto;
2525
import ch.xxx.maps.domain.model.dto.RingDto;
26-
import ch.xxx.maps.domain.model.dto.Tuple;
2726
import ch.xxx.maps.domain.model.entity.CompanySite;
2827
import ch.xxx.maps.domain.model.entity.Location;
2928
import ch.xxx.maps.domain.model.entity.Polygon;
@@ -33,20 +32,22 @@
3332
public class EntityDtoMapper {
3433

3534
public CompanySite mapToEntity(CompanySiteDto dto, CompanySite entity) {
35+
record Polygons(PolygonDto dto, Polygon entity) {};
3636
entity.setAtDate(dto.getAtDate() == null ? LocalDate.now() : dto.getAtDate());
3737
entity.setTitle(dto.getTitle());
38-
entity.setPolygons(dto.getPolygons().stream().flatMap(myPolygonDto -> Stream.of(new Tuple<PolygonDto, Polygon>(
38+
entity.setPolygons(dto.getPolygons().stream().flatMap(myPolygonDto -> Stream.of(new Polygons(
3939
myPolygonDto,
4040
entity.getPolygons().stream()
4141
.filter(myPolygon -> myPolygon.getId() != null && entity.getId() != null
4242
&& myPolygon.getId().equals(myPolygonDto.getId()))
4343
.findFirst().orElse(new Polygon()))))
44-
.flatMap(tuple -> Stream.of(this.mapToEntity(tuple.getA(), tuple.getB(), entity)))
44+
.flatMap(myRecord -> Stream.of(this.mapToEntity(myRecord.dto(), myRecord.entity(), entity)))
4545
.collect(Collectors.toSet()));
4646
return entity;
4747
}
4848

4949
public Polygon mapToEntity(PolygonDto dto, Polygon entity, CompanySite companySite) {
50+
record Rings(RingDto dto, Ring entity) {};
5051
entity.setBorderColor(dto.getBorderColor());
5152
entity.setLatitude(dto.getLatitude());
5253
entity.setLongitude(dto.getLongitude());
@@ -55,28 +56,29 @@ public Polygon mapToEntity(PolygonDto dto, Polygon entity, CompanySite companySi
5556
entity.setTitle(dto.getTitle());
5657
entity.setRings(
5758
dto.getRings().stream()
58-
.flatMap(myRingDto -> Stream.of(new Tuple<RingDto, Ring>(myRingDto, entity.getRings().stream()
59+
.flatMap(myRingDto -> Stream.of(new Rings(myRingDto, entity.getRings().stream()
5960
.filter(myRing -> myRing.getId() != null && myRingDto.getId() != null
6061
&& myRing.getId().equals(myRingDto.getId()))
6162
.findFirst().orElse(new Ring()))))
62-
.flatMap(myTuple -> Stream.of(this.mapToEntity(myTuple.getA(), myTuple.getB(), entity)))
63+
.flatMap(myTuple -> Stream.of(this.mapToEntity(myTuple.dto(), myTuple.entity(), entity)))
6364
.collect(Collectors.toSet()));
6465
return entity;
6566
}
6667

6768
public Ring mapToEntity(RingDto dto, Ring entity, Polygon polygon) {
69+
record Locations(LocationDto dto, Location entity) { };
6870
for (int i = 0; i < dto.getLocations().size(); i++) {
6971
dto.getLocations().get(i).setOrderId(i + 1);
7072
}
7173
entity.setPolygon(polygon);
7274
entity.setPrimaryRing(dto.isPrimaryRing());
7375
entity.setLocations(dto.getLocations().stream()
74-
.flatMap(myLocationDto -> Stream.of(new Tuple<LocationDto, Location>(myLocationDto,
76+
.flatMap(myLocationDto -> Stream.of(new Locations(myLocationDto,
7577
entity.getLocations().stream()
7678
.filter(myLocation -> myLocation.getId() != null && myLocationDto.getId() != null
7779
&& myLocation.getId().equals(myLocationDto.getId()))
7880
.findFirst().orElse(new Location()))))
79-
.flatMap(tuple -> Stream.of(this.mapToEntity(tuple.getA(), tuple.getB(), null, entity)))
81+
.flatMap(tuple -> Stream.of(this.mapToEntity(tuple.dto(), tuple.entity(), null, entity)))
8082
.collect(Collectors.toSet()));
8183
return entity;
8284
}

0 commit comments

Comments
 (0)