01: package spoon.aval.annotation.value;
02:
03: import java.lang.annotation.Annotation;
04: import java.lang.annotation.Retention;
05: import java.lang.annotation.RetentionPolicy;
06:
07: import spoon.aval.annotation.Implementation;
08: import spoon.aval.annotation.structure.AValTarget;
09: import spoon.aval.annotation.structure.Type;
10: import spoon.aval.support.validator.RefersToAnnotatedElementValidator;
11: import spoon.aval.support.validator.problemFixer.RemoveThisAnnotation;
12: import spoon.processing.ProblemFixer;
13: import spoon.processing.Severity;
14: import spoon.reflect.declaration.CtField;
15:
16: /**
17: * Validator that states that the value of an attribute of an annotation
18: * must refer to a class annotated with a certain annotation.
19: */
20: @AValTarget(CtField.class)
21: @Retention(RetentionPolicy.RUNTIME)
22: @Type(Class.class)
23: @Implementation(RefersToAnnotatedElementValidator.class)
24: public @interface RefersToAnnotatedElement {
25:
26: /**
27: * Annotation that the referred element must carry
28: */
29: Class<? extends Annotation> value();
30:
31: /**
32: * Message to report when validation fails
33: */
34: String message() default "Class \"?val\" does not carry \"?ann\" ";
35:
36: /**
37: * Severity of the validation faliure
38: */
39: Severity severity() default Severity.WARNING;
40:
41: /**
42: * The list of {@link ProblemFixer}s to propose when the validation fails.
43: */
44: Class<? extends ProblemFixer>[] fixers() default { RemoveThisAnnotation.class };
45: }
|