KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > lang > annotation > Target


1 /*
2  * @(#)Target.java 1.5 04/06/22
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.lang.annotation;
9
10 /**
11  * Indicates the kinds of program element to which an annotation type
12  * is applicable. If a Target meta-annotation is not present on an
13  * annotation type declaration, the declared type may be used on any
14  * program element. If such a meta-annotation is present, the compiler
15  * will enforce the specified usage restriction.
16  *
17  * For example, this meta-annotation indicates that the declared type is
18  * itself a meta-annotation type. It can only be used on annotation type
19  * declarations:
20  * <pre>
21  * &#064;Target(ElementType.ANNOTATION_TYPE)
22  * public &#064;interface MetaAnnotationType {
23  * ...
24  * }
25  * </pre>
26  * This meta-annotation indicates that the declared type is intended solely
27  * for use as a member type in complex annotation type declarations. It
28  * cannot be used to annotate anything directly:
29  * <pre>
30  * &#064;Target({})
31  * public &#064;interface MemberType {
32  * ...
33  * }
34  * </pre>
35  * It is a compile-time error for a single ElementType constant to
36  * appear more than once in a Target annotation. For example, the
37  * following meta-annotation is illegal:
38  * <pre>
39  * &#064;Target({ElementType.FIELD, ElementType.METHOD, ElementType.FIELD})
40  * public &#064;interface Bogus {
41  * ...
42  * }
43  * </pre>
44  */

45 @Documented JavaDoc
46 @Retention JavaDoc(RetentionPolicy.RUNTIME)
47 @Target JavaDoc(ElementType.ANNOTATION_TYPE)
48 public @interface Target {
49     ElementType JavaDoc[] value();
50 }
51
Popular Tags