Files
timekeep-backend/src/main/java/de/pnreichmuth/timekeep_backend/wsto/StationWSTO.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()
);
}
}