// "Collapse loop with stream 'max()'" "true-preview" import java.util.Collection; class Scratch { native int scale(); private static Integer getMaxScale(Collection updated) { int maxScale = updated.stream().mapToInt(Scratch::scale).filter(b -> b >= 0).max().orElse(0); return maxScale; } }