Help AI coding agents use Java Streams and Collectors well in new code, review, and cleanup without replacing one antipattern with another.
100
100%
Does it follow best practices?
Impact
100%
2.17xAverage score across 4 eval scenarios
Passed
No known issues
Use $java-streams to create OfferAvailability.java. Assume Java 24.
Implement:
List<Offer> availableOffers(List<Offer> offers)Rules:
AvailabilityApi.lookup(offer.id()) is a blocking remote call.availableOffers(offers) call, run at most 8 in-flight
AvailabilityApi.lookup(...) calls at the same time.Offer::rank, then Offer::id.parallelStream() or .parallel().null as a sentinel for unavailable offers.Use these nested types:
record Offer(String id, int rank) {}
record Availability(boolean show, String region) {}
static final class AvailabilityApi {
static Availability lookup(String id) {
throw new UnsupportedOperationException("provided by production");
}
}