List<Pair<ArrivalAndDepartureInstance>> results, boolean findDepartures,
boolean fillBlockLocations) {
if (CollectionsLibrary.isEmpty(locations)) {
ArrivalAndDepartureInstance instanceFrom = createArrivalAndDepartureForStopTimeInstance(
stiFrom, frequencyOffsetTime);
ArrivalAndDepartureInstance instanceTo = createArrivalAndDepartureForStopTimeInstance(
stiTo, frequencyOffsetTime);
/**
* We don't need to get the scheduled location of a vehicle unless its in
* our arrival window
*/
if (isArrivalAndDeparturePairInRange(instanceFrom, instanceTo, fromTime,
toTime, findDepartures)) {
if (fillBlockLocations) {
BlockLocation scheduledLocation = _blockLocationService.getScheduledLocationForBlockInstance(
blockInstance, targetTime.getTargetTime());
if (scheduledLocation != null) {
applyBlockLocationToInstance(instanceFrom, scheduledLocation,
targetTime.getTargetTime());
applyBlockLocationToInstance(instanceTo, scheduledLocation,
targetTime.getTargetTime());
}
}
results.add(Tuples.pair(instanceFrom, instanceTo));
}
} else {
for (BlockLocation location : locations) {
ArrivalAndDepartureInstance instanceFrom = createArrivalAndDepartureForStopTimeInstance(
stiFrom, frequencyOffsetTime);
ArrivalAndDepartureInstance instanceTo = createArrivalAndDepartureForStopTimeInstance(
stiTo, frequencyOffsetTime);
applyBlockLocationToInstance(instanceFrom, location,
targetTime.getTargetTime());
applyBlockLocationToInstance(instanceTo, location,