org.opentripplanner.gtfs.mapping.ServiceCalendarDateMapper 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.gtfs.mapping;
import org.opentripplanner.model.calendar.ServiceCalendarDate;
import org.opentripplanner.util.MapUtils;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/** Responsible for mapping GTFS ServiceCalendarDate into the OTP model. */
class ServiceCalendarDateMapper {
private Map mappedServiceDates = new HashMap<>();
Collection map(
Collection allServiceDates) {
return MapUtils.mapToList(allServiceDates, this::map);
}
/** Map from GTFS to OTP model, {@code null} safe. */
ServiceCalendarDate map(org.onebusaway.gtfs.model.ServiceCalendarDate orginal) {
return orginal == null ? null : mappedServiceDates.computeIfAbsent(orginal, this::doMap);
}
private ServiceCalendarDate doMap(org.onebusaway.gtfs.model.ServiceCalendarDate rhs) {
return new ServiceCalendarDate(
AgencyAndIdMapper.mapAgencyAndId(rhs.getServiceId()),
ServiceDateMapper.mapServiceDate(rhs.getDate()),
rhs.getExceptionType()
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy