296 * @return the type of the element as viewed from the containing type |
299 * @return the type of the element as viewed from the containing type |
297 * @throws IllegalArgumentException if the element is not a valid one |
300 * @throws IllegalArgumentException if the element is not a valid one |
298 * for the given type |
301 * for the given type |
299 */ |
302 */ |
300 TypeMirror asMemberOf(DeclaredType containing, Element element); |
303 TypeMirror asMemberOf(DeclaredType containing, Element element); |
|
304 |
|
305 /** |
|
306 * Returns the annotations targeting the type. |
|
307 * |
|
308 * @param type the targeted type |
|
309 * @return the type annotations targeting the type |
|
310 */ |
|
311 List<? extends AnnotationMirror> typeAnnotationsOf(TypeMirror type); |
|
312 |
|
313 /** |
|
314 * Returns the type's annotation for the specified type if |
|
315 * such an annotation is present, else {@code null}. The |
|
316 * annotation has to be directly present on this |
|
317 * element. |
|
318 * |
|
319 * <p> The annotation returned by this method could contain an element |
|
320 * whose value is of type {@code Class}. |
|
321 * This value cannot be returned directly: information necessary to |
|
322 * locate and load a class (such as the class loader to use) is |
|
323 * not available, and the class might not be loadable at all. |
|
324 * Attempting to read a {@code Class} object by invoking the relevant |
|
325 * method on the returned annotation |
|
326 * will result in a {@link MirroredTypeException}, |
|
327 * from which the corresponding {@link TypeMirror} may be extracted. |
|
328 * Similarly, attempting to read a {@code Class[]}-valued element |
|
329 * will result in a {@link MirroredTypesException}. |
|
330 * |
|
331 * <blockquote> |
|
332 * <i>Note:</i> This method is unlike others in this and related |
|
333 * interfaces. It operates on runtime reflective information — |
|
334 * representations of annotation types currently loaded into the |
|
335 * VM — rather than on the representations defined by and used |
|
336 * throughout these interfaces. Consequently, calling methods on |
|
337 * the returned annotation object can throw many of the exceptions |
|
338 * that can be thrown when calling methods on an annotation object |
|
339 * returned by core reflection. This method is intended for |
|
340 * callers that are written to operate on a known, fixed set of |
|
341 * annotation types. |
|
342 * </blockquote> |
|
343 * |
|
344 * @param <A> the annotation type |
|
345 * @param type the targeted type |
|
346 * @param annotationType the {@code Class} object corresponding to |
|
347 * the annotation type |
|
348 * @return the type's annotation for the specified annotation |
|
349 * type if present on the type, else {@code null} |
|
350 * |
|
351 * @see Element#getAnnotationMirrors() |
|
352 * @see EnumConstantNotPresentException |
|
353 * @see AnnotationTypeMismatchException |
|
354 * @see IncompleteAnnotationException |
|
355 * @see MirroredTypeException |
|
356 * @see MirroredTypesException |
|
357 */ |
|
358 <A extends Annotation> A typeAnnotationOf(TypeMirror type, Class<A> annotationType); |
|
359 |
|
360 /** |
|
361 * Returns the annotations targeting the method receiver type. |
|
362 * |
|
363 * @param type the targeted type |
|
364 * @return the receiver type of the executable type |
|
365 */ |
|
366 TypeMirror receiverTypeOf(ExecutableType type); |
|
367 |
|
368 /** |
|
369 * Returns the type's annotation for the specified executable type |
|
370 * receiver if such an annotation is present, else {@code null}. The |
|
371 * annotation has to be directly present on this |
|
372 * element. |
|
373 * |
|
374 * <p> The annotation returned by this method could contain an element |
|
375 * whose value is of type {@code Class}. |
|
376 * This value cannot be returned directly: information necessary to |
|
377 * locate and load a class (such as the class loader to use) is |
|
378 * not available, and the class might not be loadable at all. |
|
379 * Attempting to read a {@code Class} object by invoking the relevant |
|
380 * method on the returned annotation |
|
381 * will result in a {@link MirroredTypeException}, |
|
382 * from which the corresponding {@link TypeMirror} may be extracted. |
|
383 * Similarly, attempting to read a {@code Class[]}-valued element |
|
384 * will result in a {@link MirroredTypesException}. |
|
385 * |
|
386 * <blockquote> |
|
387 * <i>Note:</i> This method is unlike others in this and related |
|
388 * interfaces. It operates on runtime reflective information — |
|
389 * representations of annotation types currently loaded into the |
|
390 * VM — rather than on the representations defined by and used |
|
391 * throughout these interfaces. Consequently, calling methods on |
|
392 * the returned annotation object can throw many of the exceptions |
|
393 * that can be thrown when calling methods on an annotation object |
|
394 * returned by core reflection. This method is intended for |
|
395 * callers that are written to operate on a known, fixed set of |
|
396 * annotation types. |
|
397 * </blockquote> |
|
398 * |
|
399 * @param <A> the annotation type |
|
400 * @param type the method type |
|
401 * @param annotationType the {@code Class} object corresponding to |
|
402 * the annotation type |
|
403 * @return the type's annotation for the specified annotation |
|
404 * type if present on the type, else {@code null} |
|
405 * |
|
406 * @see Element#getAnnotationMirrors() |
|
407 * @see EnumConstantNotPresentException |
|
408 * @see AnnotationTypeMismatchException |
|
409 * @see IncompleteAnnotationException |
|
410 * @see MirroredTypeException |
|
411 * @see MirroredTypesException |
|
412 */ |
|
413 // TODO: no longer needed? |
|
414 // <A extends Annotation> A receiverTypeAnnotationOf(ExecutableType type, Class<A> annotationType); |
|
415 |
301 } |
416 } |