
107
6
장
자바에서 코틀린 컬렉션으로
}
public static List<Journey> longestJourneysIn(
List<Journey> journeys,
int limit
) {
journeys.sort(comparing(Journey::getDuration).reversed());
➊
var actualLimit = Math.min(journeys.size(), limit);
return journeys.subList(0, actualLimit);
}
public static List<List<Journey>> routesToShowFor(String itineraryId) {
var routes = routesFor(itineraryId);
removeUnbearableRoutes(routes);
return routes;
}
private static void removeUnbearableRoutes(List<List<Journey>> routes) {
routes.removeIf(route -> sufferScoreFor(route) > 10);
}
private static int sufferScore(
List<Journey> longestJourneys,
Location ...