public StopsForRouteV2Bean getStopsForRoute( StopsForRouteBean stopsForRoute, boolean includePolylines) { StopsForRouteV2Bean bean = new StopsForRouteV2Bean(); RouteBean route = stopsForRoute.getRoute(); if (route != null) { addToReferences(route); bean.setRouteId(route.getId()); } List<String> stopIds = new ArrayList<String>(); for (StopBean stop : stopsForRoute.getStops()) { stopIds.add(stop.getId()); addToReferences(stop); } bean.setStopIds(stopIds); bean.setStopGroupings(stopsForRoute.getStopGroupings()); if (!includePolylines) { for (StopGroupingBean grouping : stopsForRoute.getStopGroupings()) { for (StopGroupBean group : grouping.getStopGroups()) group.setPolylines(null); } } if (includePolylines) bean.setPolylines(stopsForRoute.getPolylines()); return bean; }
private StopGroupBean filterNonRevenueStopGroup(String agencyId, StopGroupBean group) { List<String> stopIds = filterNonRevenueStopIds(agencyId, group.getStopIds()); group.setStopIds(stopIds); if (group.getSubGroups() != null) { List<StopGroupBean> subGroups = filterNonRevenueStopGroups(agencyId, group.getSubGroups()); if (!subGroups.isEmpty()) group.setSubGroups(subGroups); else group.setSubGroups(null); } if (group.getStopIds().isEmpty() && group.getSubGroups() == null) return null; return group; }