public final class Parameter extends Object implements AnnotatedElement
Parameter提供了有关方法参数的信息,包括其名称和修饰符。
它还提供了获取参数属性的替代方法。
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
基于可执行文件和索引进行比较。
|
AnnotatedType |
getAnnotatedType()
返回一个AnnotatedType对象,它表示使用一个类型来指定此参数表示的形式参数的类型。
|
<T extends Annotation> |
getAnnotation(类<T> annotationClass)
返回该元素的,如果这样的注释
,否则返回null指定类型的注释。
|
Annotation[] |
getAnnotations()
返回此元素上
存在的注释。
|
<T extends Annotation> |
getAnnotationsByType(类<T> annotationClass)
返回与此元素相关
联的注释 。
|
<T extends Annotation> |
getDeclaredAnnotation(类<T> annotationClass)
如果这样的注释
直接存在 ,则返回指定类型的元素注释,否则返回null。
|
Annotation[] |
getDeclaredAnnotations()
返回
直接存在于此元素上的注释。
|
<T extends Annotation> |
getDeclaredAnnotationsByType(类<T> annotationClass)
如果此类注释
直接存在或
间接存在,则返回该元素的注释(指定类型)。
|
Executable |
getDeclaringExecutable()
返回
Executable ,它声明此参数。
|
int |
getModifiers()
获取由此
Parameter对象表示的参数的修饰符标志。
|
String |
getName()
返回参数的名称。
|
Type |
getParameterizedType()
返回一个
Type对象标识参数化的类型由该表示的参数
Parameter对象。
|
类<?> |
getType()
返回一个
类对象标识了此表示的参数的声明类型
Parameter对象。
|
int |
hashCode()
根据可执行文件的哈希码和索引返回哈希码。
|
boolean |
isImplicit()
如果此参数在源代码中隐式声明,则返回 true ;
返回false其他。
|
boolean |
isNamePresent()
如果参数具有根据类文件的名称,则返回true;
否则返回false。
|
boolean |
isSynthetic()
返回 true如果此参数既不是在源代码中隐式也不显式声明;
返回false否则。
|
boolean |
isVarArgs()
如果此参数表示可变参数列表,则返回 true ;
返回false否则。
|
String |
toString()
返回描述此参数的字符串。
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitisAnnotationPresentpublic boolean equals(Object obj)
equals在
Object
obj - 要比较的对象。
Object.hashCode() , HashMap
public int hashCode()
hashCode在
Object
Object.equals(java.lang.Object) ,
System.identityHashCode(java.lang.Object)
public boolean isNamePresent()
public String toString()
public Executable getDeclaringExecutable()
Executable ,它声明了此参数。
Executable声明此参数。
public int getModifiers()
Parameter对象表示的参数的修饰符标志。
public String getName()
public Type getParameterizedType()
Type对象标识参数化的类型由该表示的参数
Parameter对象。
Type对象识别由该对象表示的参数化的类型的参数的
public 类<?> getType()
类对象标识了此表示的参数的声明类型
Parameter对象。
类对象表示的参数的声明类型的Class对象
public AnnotatedType getAnnotatedType()
AnnotatedType对象,表示使用一个类型来指定此参数表示的形式参数的类型
public boolean isImplicit()
true ;
返回false否则。
public boolean isSynthetic()
true如果此参数既不在源代码中隐式也不显式声明;
返回false其他。
public boolean isVarArgs()
true ;
返回false其他。
true如果只有这个参数表示一个可变参数列表。
public <T extends Annotation> T getAnnotation(类<T> annotationClass)
getAnnotation中的
AnnotatedElement
T - 要查询的注释类型,如果存在则返回
annotationClass - 对应于注释类型的Class对象
NullPointerException - 如果给定的注释类为空
public <T extends Annotation> T[] getAnnotationsByType(类<T> annotationClass)
AnnotatedElement.getAnnotation(Class)之间的区别在于该方法检测其参数是否是可重复注释类型 (JLS 9.6),如果是,则尝试通过“查看”容器注释来查找该类型的一个或多个注释。
该方法的调用者可以自由修改返回的数组;
它将对返回给其他调用者的数组没有影响。
getAnnotationsByType中的
AnnotatedElement
T - 查询的注释类型,如果存在则返回
annotationClass - 对应于注释类型的Class对象
NullPointerException - 如果给定的注释类为空
public Annotation[] getDeclaredAnnotations()
getDeclaredAnnotations在接口
AnnotatedElement
public <T extends Annotation> T getDeclaredAnnotation(类<T> annotationClass)
AnnotatedElement复制
getDeclaredAnnotation中的
AnnotatedElement
T - 查询的注释类型,如果直接出现则返回
annotationClass - 对应于注释类型的Class对象
NullPointerException - 如果给定的注释类为空
public <T extends Annotation> T[] getDeclaredAnnotationsByType(类<T> annotationClass)
AnnotatedElement复制
AnnotatedElement.getDeclaredAnnotation(Class)之间的区别在于该方法检测其参数是否是可重复注释类型 (JLS 9.6),以及如果是,尝试通过“查看”容器注释(如果存在)来查找该类型的一个或多个注释。
该方法的调用者可以自由修改返回的数组;
它将对返回给其他调用者的数组没有影响。
getDeclaredAnnotationsByType在接口
AnnotatedElement
T - 直接或间接出现时查询和返回的注释类型
annotationClass - 对应于注释类型的Class对象
NullPointerException - 如果给定的注释类为空
public Annotation[] getAnnotations()
getAnnotations在界面
AnnotatedElement
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.