org.opentripplanner.gtfs.mapping.ServiceCalendarMapper 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 static org.opentripplanner.gtfs.mapping.AgencyAndIdMapper.mapAgencyAndId;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.opentripplanner.model.calendar.ServiceCalendar;
import org.opentripplanner.util.MapUtils;
/** Responsible for mapping GTFS ServiceCalendar into the OTP model. */
class ServiceCalendarMapper {
private final Map mappedCalendars = new HashMap<>();
Collection map(
Collection allServiceCalendars
) {
return MapUtils.mapToList(allServiceCalendars, this::map);
}
/** Map from GTFS to OTP model, {@code null} safe. */
ServiceCalendar map(org.onebusaway.gtfs.model.ServiceCalendar orginal) {
return orginal == null ? null : mappedCalendars.computeIfAbsent(orginal, this::doMap);
}
private ServiceCalendar doMap(org.onebusaway.gtfs.model.ServiceCalendar rhs) {
ServiceCalendar lhs = new ServiceCalendar();
lhs.setServiceId(mapAgencyAndId(rhs.getServiceId()));
lhs.setMonday(rhs.getMonday());
lhs.setTuesday(rhs.getTuesday());
lhs.setWednesday(rhs.getWednesday());
lhs.setThursday(rhs.getThursday());
lhs.setFriday(rhs.getFriday());
lhs.setSaturday(rhs.getSaturday());
lhs.setSunday(rhs.getSunday());
lhs.setPeriod(ServiceDateMapper.mapServiceDateInterval(rhs.getStartDate(), rhs.getEndDate()));
return lhs;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy