KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > template > Parameter


1 package spoon.template;
2
3 import java.lang.annotation.ElementType JavaDoc;
4 import java.lang.annotation.Retention JavaDoc;
5 import java.lang.annotation.RetentionPolicy JavaDoc;
6 import java.lang.annotation.Target JavaDoc;
7
8 import spoon.support.template.DefaultParameterMatcher;
9 import spoon.support.template.ParameterMatcher;
10
11 /**
12  * This annotation should be placed on templates' fields or methods to indicate
13  * that they represent template parameters. It is only mandatory for names,
14  * literals, and types, where it avoids having to use
15  * {@link spoon.template.TemplateParameter} and allows for the direct accesses
16  * of the parameters. A parameter is never considered as a templated element and
17  * it is not necessary to annotate it with a {@link Local} annotation.
18  */

19 @Retention JavaDoc(RetentionPolicy.RUNTIME)
20 @Target JavaDoc( {
21     ElementType.FIELD, ElementType.METHOD
22 })
23 public @interface Parameter {
24     /**
25      * Defines the name of the parameter (optional, mostly to avoid name
26      * clashes). By default, the name of a template parameter is the simple name
27      * of the annotated field. However, in some cases, it can be useful to set a
28      * different name to a parameter in order to avoid name clashes, in
29      * particular when a parameter represents the name of a templated field. For
30      * instance:
31      *
32      * <pre>
33      * class T extends Template {
34      * // this parameter will contain the actual value of the _i_ field's name
35      * &#64;Parameter(&quot;_i_&quot;)
36      * String __i_;
37      *
38      * int _i_;
39      * }
40      * </pre>
41      */

42     String JavaDoc value() default "";
43
44     /**
45      * Precises the type of the parameter matcher for this particular parameter
46      * when using the {@link spoon.template.TemplateMatcher} engine (optional). By
47      * default, the parameter will match under any form. Specifying an
48      * implementation of {@link ParameterMatcher} here allows the matching of
49      * more specific forms.
50      */

51     Class JavaDoc<? extends ParameterMatcher> match() default DefaultParameterMatcher.class;
52 }
53
Popular Tags