You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SwitchInAround.java 528B

123456789101112131415161718192021222324252627
  1. import org.aspectj.testing.Tester;
  2. public class SwitchInAround {
  3. public static void main(String[] args) {
  4. SwitchInAround o = new SwitchInAround();
  5. Tester.checkEqual(o.doit(1), "1");
  6. Tester.checkEqual(o.doit(2), "2");
  7. Tester.checkEqual(o.doit(3), "default");
  8. }
  9. public String doit(int i) {
  10. return "doit";
  11. }
  12. }
  13. privileged aspect A {
  14. String around(int index): args(index) && call(String doit(int)) {
  15. switch(index) {
  16. case 1:
  17. return "1";
  18. case 2:
  19. return "2";
  20. default:
  21. return "default";
  22. }
  23. }
  24. }