List < Transfer > getTransfersToStop ( String toStopId , String toRouteId ) { final List < Transfer > allInboundTransfers = transfersToStop . getOrDefault ( toStopId , Collections . emptyList ( ) ) ; final Map < String , List < Transfer > > byFromStop = allInboundTransfers . stream ( ) . filter ( t -> t . transfer_type == 0 || t . transfer_type == 2 ) . filter ( t -> t . to_route_id == null || toRouteId . equals ( t . to_route_id ) ) . collect ( Collectors . groupingBy ( t -> t . from_stop_id ) ) ; final List < Transfer > result = new ArrayList <> ( ) ; byFromStop . forEach ( ( fromStop , transfers ) -> { routesByStop . getOrDefault ( fromStop , Collections . emptySet ( ) ) . forEach ( fromRoute -> { final Transfer mostSpecificRule = findMostSpecificRule ( transfers , fromRoute , toRouteId ) ; final Transfer myRule = new Transfer ( ) ; myRule . to_route_id = toRouteId ; myRule . from_route_id = fromRoute ; myRule . to_stop_id = mostSpecificRule . to_stop_id ; myRule . from_stop_id = mostSpecificRule . from_stop_id ; myRule . transfer_type = mostSpecificRule . transfer_type ; myRule . min_transfer_time = mostSpecificRule . min_transfer_time ; myRule . from_trip_id = mostSpecificRule . from_trip_id ; myRule . to_trip_id = mostSpecificRule . to_trip_id ; result . add ( myRule ) ; } ) ; } ) ; return result ; }
So far only the route is supported .