01: package spoon.aval.annotation.structure;
02:
03: import java.lang.annotation.Retention;
04: import java.lang.annotation.RetentionPolicy;
05:
06: import spoon.aval.annotation.Implementation;
07: import spoon.aval.support.validator.ModifierValidator;
08: import spoon.aval.support.validator.problemFixer.RemoveThisAnnotation;
09: import spoon.processing.ProblemFixer;
10: import spoon.processing.Severity;
11: import spoon.reflect.declaration.CtAnnotationType;
12: import spoon.reflect.declaration.ModifierKind;
13:
14: /**
15: * Validator that states that the annotation can only be placed elements which
16: * have the required modifiers. No check is made to see if the modifier set required is valid (i.e., no error is raised
17: * if <b>public</p> and <p>private</b> are required)
18: * <p>
19: * For example if <code>@A</code> can only be placed on fields which are <p>public</p> the
20: * <code>@A</code> annotation type would be defined as:
21: *
22: * <pre>
23: * @Modifier({ModifierKind.PUBLIC})
24: * @Target(FIELD)
25: * public @interface A{}
26: * </pre>
27: *
28: * @see spoon.aval.support.validator.ModifierValidator
29: */
30: @Retention(RetentionPolicy.RUNTIME)
31: @Implementation(ModifierValidator.class)
32: @AValTarget(CtAnnotationType.class)
33: public @interface Modifier {
34:
35: ModifierKind[] value();
36:
37: /**
38: * Message to report when validation fails
39: */
40: String message() default "This is not a permited modifier";
41:
42: /**
43: * Severity of the validation faliure
44: */
45: Severity severity() default Severity.WARNING;
46:
47: /**
48: * The list of {@link ProblemFixer}s to propose
49: * when the validation fails.
50: */
51: Class<? extends ProblemFixer>[] fixers() default { RemoveThisAnnotation.class };
52:
53: }
|