87 * @return the kind of this element |
86 * @return the kind of this element |
88 */ |
87 */ |
89 ElementKind getKind(); |
88 ElementKind getKind(); |
90 |
89 |
91 /** |
90 /** |
92 * Returns the annotations that are directly present on this element. |
|
93 * |
|
94 * <p> To get inherited annotations as well, use |
|
95 * {@link Elements#getAllAnnotationMirrors(Element) getAllAnnotationMirrors}. |
|
96 * |
|
97 * @see ElementFilter |
|
98 * |
|
99 * @return the annotations directly present on this element; |
|
100 * an empty list if there are none |
|
101 */ |
|
102 List<? extends AnnotationMirror> getAnnotationMirrors(); |
|
103 |
|
104 /** |
|
105 * Returns this element's annotation for the specified type if |
|
106 * such an annotation is present, else {@code null}. The |
|
107 * annotation may be either inherited or directly present on this |
|
108 * element. |
|
109 * |
|
110 * <p> The annotation returned by this method could contain an element |
|
111 * whose value is of type {@code Class}. |
|
112 * This value cannot be returned directly: information necessary to |
|
113 * locate and load a class (such as the class loader to use) is |
|
114 * not available, and the class might not be loadable at all. |
|
115 * Attempting to read a {@code Class} object by invoking the relevant |
|
116 * method on the returned annotation |
|
117 * will result in a {@link MirroredTypeException}, |
|
118 * from which the corresponding {@link TypeMirror} may be extracted. |
|
119 * Similarly, attempting to read a {@code Class[]}-valued element |
|
120 * will result in a {@link MirroredTypesException}. |
|
121 * |
|
122 * <blockquote> |
|
123 * <i>Note:</i> This method is unlike others in this and related |
|
124 * interfaces. It operates on runtime reflective information — |
|
125 * representations of annotation types currently loaded into the |
|
126 * VM — rather than on the representations defined by and used |
|
127 * throughout these interfaces. Consequently, calling methods on |
|
128 * the returned annotation object can throw many of the exceptions |
|
129 * that can be thrown when calling methods on an annotation object |
|
130 * returned by core reflection. This method is intended for |
|
131 * callers that are written to operate on a known, fixed set of |
|
132 * annotation types. |
|
133 * </blockquote> |
|
134 * |
|
135 * @param <A> the annotation type |
|
136 * @param annotationType the {@code Class} object corresponding to |
|
137 * the annotation type |
|
138 * @return this element's annotation for the specified annotation |
|
139 * type if present on this element, else {@code null} |
|
140 * |
|
141 * @see #getAnnotationMirrors() |
|
142 * @see java.lang.reflect.AnnotatedElement#getAnnotation |
|
143 * @see EnumConstantNotPresentException |
|
144 * @see AnnotationTypeMismatchException |
|
145 * @see IncompleteAnnotationException |
|
146 * @see MirroredTypeException |
|
147 * @see MirroredTypesException |
|
148 */ |
|
149 <A extends Annotation> A getAnnotation(Class<A> annotationType); |
|
150 |
|
151 /** |
|
152 * Returns annotations that are <em>present</em> on this element. |
|
153 * |
|
154 * If there are no annotations <em>present</em> on this element, the return |
|
155 * value is an array of length 0. |
|
156 * |
|
157 * The difference between this method and {@link #getAnnotation(Class)} |
|
158 * is that this method detects if its argument is a <em>repeatable |
|
159 * annotation type</em> (JLS 9.6), and if so, attempts to find one or more |
|
160 * annotations of that type by "looking through" a container annotation. |
|
161 * |
|
162 * <p> The annotations returned by this method could contain an element |
|
163 * whose value is of type {@code Class}. |
|
164 * This value cannot be returned directly: information necessary to |
|
165 * locate and load a class (such as the class loader to use) is |
|
166 * not available, and the class might not be loadable at all. |
|
167 * Attempting to read a {@code Class} object by invoking the relevant |
|
168 * method on the returned annotation |
|
169 * will result in a {@link MirroredTypeException}, |
|
170 * from which the corresponding {@link TypeMirror} may be extracted. |
|
171 * Similarly, attempting to read a {@code Class[]}-valued element |
|
172 * will result in a {@link MirroredTypesException}. |
|
173 * |
|
174 * <blockquote> |
|
175 * <i>Note:</i> This method is unlike others in this and related |
|
176 * interfaces. It operates on runtime reflective information — |
|
177 * representations of annotation types currently loaded into the |
|
178 * VM — rather than on the representations defined by and used |
|
179 * throughout these interfaces. Consequently, calling methods on |
|
180 * the returned annotation object can throw many of the exceptions |
|
181 * that can be thrown when calling methods on an annotation object |
|
182 * returned by core reflection. This method is intended for |
|
183 * callers that are written to operate on a known, fixed set of |
|
184 * annotation types. |
|
185 * </blockquote> |
|
186 * |
|
187 * @param <A> the annotation type |
|
188 * @param annotationType the {@code Class} object corresponding to |
|
189 * the annotation type |
|
190 * @return this element's annotations for the specified annotation |
|
191 * type if present on this element, else an empty array |
|
192 * |
|
193 * @see #getAnnotationMirrors() |
|
194 * @see #getAnnotation(java.lang.Class) |
|
195 * @see java.lang.reflect.AnnotatedElement#getAnnotationsByType |
|
196 * @see EnumConstantNotPresentException |
|
197 * @see AnnotationTypeMismatchException |
|
198 * @see IncompleteAnnotationException |
|
199 * @see MirroredTypeException |
|
200 * @see MirroredTypesException |
|
201 */ |
|
202 <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType); |
|
203 |
|
204 /** |
|
205 * Returns the modifiers of this element, excluding annotations. |
91 * Returns the modifiers of this element, excluding annotations. |
206 * Implicit modifiers, such as the {@code public} and {@code static} |
92 * Implicit modifiers, such as the {@code public} and {@code static} |
207 * modifiers of interface members, are included. |
93 * modifiers of interface members, are included. |
208 * |
94 * |
209 * @return the modifiers of this element, or an empty set if there are none |
95 * @return the modifiers of this element, or an empty set if there are none |