summaryrefslogtreecommitdiffstats
path: root/tests/bugs152/pr148545/MyAspect.java
blob: b42f52b25e3c881be76852994b3bbc33f04878a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.Arrays;

privileged public aspect MyAspect {

        Object around(MyClass o, MyAnnotation a) :
                        execution(@MyAnnotation * *(..)) &&
                        target(o) &&
                        @annotation(a) {
                if (!isOneOf(o.getValue(), a.value()))
                        throw new IllegalStateException(
                                        o.getValue() +
                                        " is not one of " +
                                        Arrays.toString(a.value()));
                return proceed(o, a);
        }

        private static final <T> boolean isOneOf(T obj, T[] arr) {
                for (T el : arr) if (obj == el) return true;
                return false;
        }
}