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() ); } }