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.Annotation;
22: import java.lang.annotation.Retention;
23: import java.lang.annotation.RetentionPolicy;
24:
25: import spoon.aval.annotation.Implementation;
26: import spoon.aval.support.validator.ProhibitsValidator;
27: import spoon.aval.support.validator.problemFixer.RemoveThisAnnotation;
28: import spoon.processing.ProblemFixer;
29: import spoon.processing.Severity;
30: import spoon.reflect.declaration.CtAnnotationType;
31:
32: /**
33: * Validator that states that elements annotated with this annotation cannot be
34: * annotated with another one
35: * <p>
36: * For example if <code>@B</code> cannot be placed on the same element as <code>@A</code>,
37: * the declaration of <code>@B</code> would be:
38: *
39: * <p>
40: * <pre>
41: * @Prohibits(A.class)
42: * @Target(FIELD)
43: * public @interface B{}
44: * </pre>
45: * </p>
46: *
47: * @see spoon.aval.support.validator.ProhibitsValidator
48: */
49: @Retention(RetentionPolicy.RUNTIME)
50: @Implementation(ProhibitsValidator.class)
51: @AValTarget(CtAnnotationType.class)
52: public @interface Prohibits {
53: /**
54: * The other annotation
55: */
56: Class<? extends Annotation> value();
57:
58: /**
59: * Message to report when validation fails
60: */
61: String message() default "The use of this annotation prohibits @?val annotation";
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: }
|