diff options
Diffstat (limited to 'tests/features199/java18/SwitchPatternPreview2Aspect.aj')
-rw-r--r-- | tests/features199/java18/SwitchPatternPreview2Aspect.aj | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/tests/features199/java18/SwitchPatternPreview2Aspect.aj b/tests/features199/java18/SwitchPatternPreview2Aspect.aj index ee5dbbd68..4170b4d15 100644 --- a/tests/features199/java18/SwitchPatternPreview2Aspect.aj +++ b/tests/features199/java18/SwitchPatternPreview2Aspect.aj @@ -1,28 +1,26 @@ -import java.util.Locale; - aspect SwitchPatternPreview2Aspect { - Object around(Object o): execution(* doSomethingWithObject(*)) && args(o) { + Object around(Integer i): execution(* doSomethingWithInteger(*)) && args(i) { System.out.println( - switch (o) { - case -1, 1 -> "special case:" + o; - case Integer i && i > 0 -> "positive integer: " + o; - case Integer i -> "other integer: " + o; - default -> "non-integer: " + o; + switch (i) { + case null -> "value unavailable: " + i; + case -1, 1 -> "absolute value 1: " + i; + case Integer value && value > 0 -> "positive integer: " + i; + default -> "other integer: " + i; } ); - return proceed(o); + return proceed(i); } } class Application { public static void main(String[] args) { - doSomethingWithObject(-1); - doSomethingWithObject(0); - doSomethingWithObject(42); - doSomethingWithObject(-99); - doSomethingWithObject("test"); - doSomethingWithObject(null); + doSomethingWithInteger(-1); + doSomethingWithInteger(0); + doSomethingWithInteger(42); + doSomethingWithInteger(-99); + doSomethingWithInteger(Integer.valueOf(123)); + doSomethingWithInteger(null); } - public static Object doSomethingWithObject(Object o) { return o; } + public static Object doSomethingWithInteger(Integer o) { return o; } } |