mirror of
https://github.com/PaulReichmuth/timekeep-backend.git
synced 2025-12-22 22:41:59 +00:00
begin switch to WSTO architecture
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package de.pnreichmuth.timekeep_backend.wsto;
|
||||
|
||||
import de.pnreichmuth.timekeep_backend.entities.Station;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record StationWSTO(
|
||||
String name,
|
||||
String locationName
|
||||
) {
|
||||
public StationWSTO{
|
||||
Objects.requireNonNull(locationName, "Station has to have a location");
|
||||
}
|
||||
|
||||
public static StationWSTO of(Station station){
|
||||
return new StationWSTO(
|
||||
station.getName(),
|
||||
station.getLocation()
|
||||
);
|
||||
}
|
||||
|
||||
public static Station toEntity(StationWSTO stationWSTO){
|
||||
return new Station(
|
||||
stationWSTO.name(),
|
||||
stationWSTO.locationName()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user