01: /**
02: * Spoon - http://spoon.gforge.inria.fr/
03: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
04: *
05: * This software is governed by the CeCILL-C License under French law and
06: * abiding by the rules of distribution of free software. You can use,
07: * modify and/or redistribute the software under the terms of the
08: * CeCILL-C
09: * license as circulated by CEA, CNRS and INRIA at the following URL:
10: * http://www.cecill.info.
11: *
12: * This program is distributed in the hope that it will be useful, but
13: * WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C
15: * License for more details.
16: *
17: * The fact that you are presently reading this means that you have had
18: * knowledge of the CeCILL-C license and that you accept its terms.
19: */package spoon.aval.annotation.structure;
20:
21: import java.lang.annotation.Retention;
22: import java.lang.annotation.RetentionPolicy;
23:
24: import spoon.aval.annotation.Implementation;
25: import spoon.aval.support.validator.AValTargetValidator;
26: import spoon.aval.support.validator.problemFixer.RemoveThisAnnotation;
27: import spoon.processing.ProblemFixer;
28: import spoon.processing.Severity;
29: import spoon.reflect.declaration.CtAnnotationType;
30: import spoon.reflect.declaration.CtElement;
31:
32: /**
33: * Validator that states on which elements can an annotation be places
34: *
35: * These elements (classes, interfaces) are defined through
36: * spoon.reflect.declaration classes.
37: * <p>
38: * For example, to say that an annotation can only be placed on interfaces, this
39: * would be the used:
40: *
41: * <pre>
42: * @AValTarget(CtInterface.class)
43: * public @interface Example {
44: * }
45: * </pre>
46: *
47: * @see spoon.aval.support.validator.AValTargetValidator
48: */
49: @Retention(RetentionPolicy.RUNTIME)
50: @AValTarget(CtAnnotationType.class)
51: @Implementation(AValTargetValidator.class)
52: public @interface AValTarget {
53: /**
54: * The annotation can only be placed on declarations of this kind
55: */
56: Class<? extends CtElement> value();
57:
58: /**
59: * Message to report when validation fails
60: */
61: String message() default "This annotation can only be placed on ?val";
62:
63: /**
64: * Severity of the validation faliure
65: */
66: Severity severity() default Severity.WARNING;
67:
68: /**
69: * The list of {@link ProblemFixer}s to propose
70: * when the validation fails.
71: */
72: Class<? extends ProblemFixer>[] fixers() default { RemoveThisAnnotation.class };
73:
74: }
|