mirror of
https://github.com/PaulReichmuth/timekeep-backend.git
synced 2025-12-22 22:41:59 +00:00
29 lines
684 B
Java
29 lines
684 B
Java
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()
|
|
);
|
|
}
|
|
}
|