public interface AnnotatedConstruct
在下面的定义,诠释一已注释类型在。如果在是一个可重复的注释类型,含注释类型ATC。
注释一直接出现在构建C如果:
通常,如果一个确切的注释类型在出现在表示C源代码,然后一显式声明为申请如果有在型目前C多注释,那么在是重复的注释类型,类型的ATC注释是隐式声明对C.
源代码表示RuntimeVisibleAnnotations
或类文件RuntimeVisibleParameterAnnotations
属性。注释一是目前构建C如果:
value
标注方法的结果。Modifier and Type | Method and Description |
---|---|
<A extends Annotation> |
getAnnotation(类<A> annotationType)
如果这样的诠释是返回指定类型的这种构造的诠释,其他
null 。
|
List<? extends AnnotationMirror> |
getAnnotationMirrors()
返回直接存在于此结构上的注释。
|
<A extends Annotation> |
getAnnotationsByType(类<A> annotationType)
返回与此结构关联的注释。
|
List<? extends AnnotationMirror> getAnnotationMirrors()
<A extends Annotation> A getAnnotation(类<A> annotationType)
null
。
此方法返回的注释可以包含一个元素的值的类型是类
。这个值不能直接返回:查找和加载类的必要信息(如类装载器使用)不可用,并可能无法加载所有的类。试图读取一个类
对象通过调用返回的注释相关的方法将导致一个MirroredTypeException
,从中可提取出相应的TypeMirror
。同样,试图读一Class[]
-valued元素将导致MirroredTypesException
。
Note: This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation types currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation types.
A
的注释类型
annotationType
-对应的注释类型的
类
对象
null
getAnnotationMirrors()
,
AnnotatedElement.getAnnotation(java.lang.Class<T>)
,
EnumConstantNotPresentException
,
AnnotationTypeMismatchException
,
IncompleteAnnotationException
,
MirroredTypeException
,
MirroredTypesException
<A extends Annotation> A[] getAnnotationsByType(类<A> annotationType)
getAnnotation(Class)
之间的区别是,该方法检测如果它的参数是一个可重复的注释类型,如果是这样的话,试图找到一个或更多的注释,通过“浏览”式容器标注。
此方法返回的注释可以包含一个元素的值的类型是类
。这个值不能直接返回:查找和加载类的必要信息(如类装载器使用)不可用,并可能无法加载所有的类。试图读取一个类
对象通过调用返回的注释相关的方法将导致一个MirroredTypeException
,从中可提取出相应的TypeMirror
。同样,试图读一Class[]
-valued元素将导致MirroredTypesException
。
Note: This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation types currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation types.
A
的注释类型
annotationType
-对应的注释类型的
类
对象
getAnnotationMirrors()
,
getAnnotation(Class)
,
AnnotatedElement.getAnnotationsByType(Class)
,
EnumConstantNotPresentException
,
AnnotationTypeMismatchException
,
IncompleteAnnotationException
,
MirroredTypeException
,
MirroredTypesException
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.