
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
The newest version!
package org.opentripplanner.gtfs.mapping;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.opentripplanner.framework.collection.MapUtils;
import org.opentripplanner.model.calendar.ServiceCalendarDate;
/** Responsible for mapping GTFS ServiceCalendarDate into the OTP model. */
class ServiceCalendarDateMapper {
private final 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.mapLocalDate(rhs.getDate()),
rhs.getExceptionType()
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy