Downgrade Java 8 streams to Java 7 loops in Intellij IDEA
Yes, IntelliJ has "Replace Stream API chain with loop" refactor option. It pops up after pressing Alt+Enter
after placing cursor on the Arrays.stream()
method:
It will produce code like:
long count = 0L;
long limit = 2;
Set<Integer> uniqueValues = new HashSet<>();
for (int i : new int[]{1, 2, 3}) {
if (uniqueValues.add(i)) {
if (limit-- == 0) break;
count++;
}
}
System.out.println(count);
For the option to work the project language level has to be 8 or higher.