
org.opentripplanner.api.mapping.TripPlanMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.api.mapping;
import java.util.Date;
import java.util.Locale;
import org.opentripplanner.api.model.ApiTripPlan;
import org.opentripplanner.model.plan.TripPlan;
public class TripPlanMapper {
private final ItineraryMapper itineraryMapper;
private final PlaceMapper placeMapper;
public TripPlanMapper(Locale locale, boolean addIntermediateStops) {
this.itineraryMapper = new ItineraryMapper(locale, addIntermediateStops);
this.placeMapper = new PlaceMapper(locale);
}
public ApiTripPlan mapTripPlan(TripPlan domain) {
if (domain == null) {
return null;
}
ApiTripPlan api = new ApiTripPlan();
api.date = Date.from(domain.date);
// The origin/destination do not have arrival/depature times; Hence {@code null} is used.
api.from = placeMapper.mapPlace(domain.from, null, null, null, null);
api.to = placeMapper.mapPlace(domain.to, null, null, null, null);
api.itineraries = itineraryMapper.mapItineraries(domain.itineraries);
return api;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy