mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-18 08:50:57 +07:00
23 lines
605 B
Java
23 lines
605 B
Java
// "Simplify 'pureConsumer(...)' to true extracting side effects" "true-preview"
|
|
import org.jetbrains.annotations.Contract;
|
|
|
|
public class Main {
|
|
private static int counter = 0;
|
|
|
|
public static void main(String[] args) {
|
|
while (true) {
|
|
sideEffect();
|
|
if (!(counter < 5)) break;
|
|
System.out.println(counter);
|
|
}
|
|
}
|
|
|
|
@Contract(value = "!null->true;null->false", pure = true)
|
|
private static boolean pureConsumer(Object consumed) {
|
|
return consumed != null;
|
|
}
|
|
|
|
private static int sideEffect() {
|
|
return counter++;
|
|
}
|
|
} |