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, modify
07: * and/or redistribute the software under the terms of the CeCILL-C license as
08: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
09: *
10: * This program is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
13: *
14: * The fact that you are presently reading this means that you have had
15: * knowledge of the CeCILL-C license and that you accept its terms.
16: */
17:
18: package spoon.template;
19:
20: import java.lang.annotation.ElementType;
21: import java.lang.annotation.Retention;
22: import java.lang.annotation.RetentionPolicy;
23: import java.lang.annotation.Target;
24:
25: import spoon.support.template.DefaultParameterMatcher;
26: import spoon.support.template.ParameterMatcher;
27:
28: /**
29: * This annotation should be placed on templates' fields or methods to indicate
30: * that they represent template parameters. It is only mandatory for names,
31: * literals, and types, where it avoids having to use
32: * {@link spoon.template.TemplateParameter} and allows for the direct accesses
33: * of the parameters. A parameter is never considered as a templated element and
34: * it is not necessary to annotate it with a {@link Local} annotation.
35: */
36: @Retention(RetentionPolicy.RUNTIME)
37: @Target({ElementType.FIELD,ElementType.METHOD})
38: public @interface Parameter {
39: /**
40: * Defines the name of the parameter (optional, mostly to avoid name
41: * clashes). By default, the name of a template parameter is the simple name
42: * of the annotated field. However, in some cases, it can be useful to set a
43: * different name to a parameter in order to avoid name clashes, in
44: * particular when a parameter represents the name of a templated field. For
45: * instance:
46: *
47: * <pre>
48: * class T extends Template {
49: * // this parameter will contain the actual value of the _i_ field's name
50: * \@Parameter("_i_")
51: * String __i_;
52: *
53: * int _i_;
54: * }
55: * </pre>
56: */
57: String value() default "";
58:
59: /**
60: * Precises the type of the parameter matcher for this particular parameter
61: * when using the {@link spoon.template.TemplateMatcher} engine (optional).
62: * By default, the parameter will match under any form. Specifying an
63: * implementation of {@link ParameterMatcher} here allows the matching of
64: * more specific forms.
65: */
66: Class<? extends ParameterMatcher> match() default DefaultParameterMatcher.class;
67: }
|