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 InvoiceBoundsAndTemperatures.java. Assume Java 17.
Implement:
Bounds<Invoice, Invoice> invoiceTotalBounds(List<Invoice> invoices)
List<Reading> readingsBeforeFirstOverheat(List<Reading> readings, double maxSafeTemperature)
List<Reading> readingsAfterInitialSafeRun(List<Reading> readings, double maxSafeTemperature)Rules:
invoiceTotalBounds should return the lowest-total and highest-total invoices. For an empty
invoice list, both bounds values should be null.readings is in chronological order.readingsBeforeFirstOverheat returns the readings from the start of the list until the first
reading where temperatureCelsius > maxSafeTemperature.readingsAfterInitialSafeRun skips the readings from the start of the list while
temperatureCelsius <= maxSafeTemperature, then returns everything after that.Use nested records:
record Invoice(String id, BigDecimal total) {}
record Reading(long sequence, double temperatureCelsius) {}
record Bounds<L, R>(L low, R high) {}