All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.gtfs.mapping.ServiceCalendarDateMapper Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
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