Class TripMergeStrategy

All Implemented Interfaces:
EntityMergeStrategy

public class TripMergeStrategy extends AbstractIdentifiableSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>
Entity merge strategy for handling Trip entities. This strategy also handles merging the StopTime entities associated with each trip.
Author:
bdferris
  • Constructor Details

    • TripMergeStrategy

      public TripMergeStrategy()
  • Method Details

    • getEntityTypes

      public void getEntityTypes(Collection<Class<?>> entityTypes)
      Recall that we handle StopTime entities in addition to Trip entities.
      Specified by:
      getEntityTypes in interface EntityMergeStrategy
      Overrides:
      getEntityTypes in class AbstractSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>
      Parameters:
      entityTypes - the handled types should be added to this output collection.
    • rejectDuplicateOverDifferences

      protected boolean rejectDuplicateOverDifferences(GtfsMergeContext context, org.onebusaway.gtfs.model.Trip sourceEntity, org.onebusaway.gtfs.model.Trip targetDuplicate)
      Even if we have detected that two trips are duplicates, they might have slight differences that prevent them from being represented as one merged trip. For example, if a trip in a subsequent feed adds, removes, or modifies a stop time, we might avoid merging the two trips such that the schedule is correct in the merged feed.

      TODO: Think about how this should be applied in relation to the service calendars of the two trips.

      Overrides:
      rejectDuplicateOverDifferences in class AbstractSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>
      Parameters:
      context -
      sourceEntity -
      targetDuplicate -
      Returns:
    • replaceDuplicateEntry

      protected void replaceDuplicateEntry(GtfsMergeContext context, org.onebusaway.gtfs.model.Trip oldTrip, org.onebusaway.gtfs.model.Trip newTrip)
      Description copied from class: AbstractSingleEntityMergeStrategy
      If we've detected a duplicate for an entity in the source feed with some entity in the merged output feed, we want to replace all references to the old entity with the new merged entity. Sub-classes will override this method to provide logic specific to particular entity types, as it relates to updating entity references.
      Specified by:
      replaceDuplicateEntry in class AbstractSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>
      Parameters:
      context -
      oldTrip - the old entity in the source feed that should be replaced
      newTrip - the new entity in the output merged feed that duplicates the old entity
    • save

      protected void save(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity)
      Description copied from class: AbstractIdentifiableSingleEntityMergeStrategy
      Saves the specified entity to the merged output feed. If the raw id of the entity duplicates an existing entity in the output feed, its id will be renamed.
      Overrides:
      save in class AbstractIdentifiableSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>
      Parameters:
      context -
      entity -