public final class Parameter extends Objectimplements AnnotatedElement
Parameter provides information about method parameters, including its name and modifiers. It also provides an alternate means of obtaining attributes for the parameter.
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object
Compares based on the executable and the index.
|
AnnotatedType |
getAnnotatedType()
Returns an AnnotatedType object that represents the use of a type to specify the type of the formal parameter represented by this Parameter.
|
<T extends Annotation |
getAnnotation(Class
Returns this element's annotation for the specified type if such an annotation is
present, else null.
|
Annotation |
getAnnotations()
Returns annotations that are
present on this element.
|
<T extends Annotation |
getAnnotationsByType(Class
Returns annotations that are
associated with this element.
|
<T extends Annotation |
getDeclaredAnnotation(Class
Returns this element's annotation for the specified type if such an annotation is
directly present, else null.
|
Annotation |
getDeclaredAnnotations()
Returns annotations that are
directly present on this element.
|
<T extends Annotation |
getDeclaredAnnotationsByType(Class
Returns this element's annotation(s) for the specified type if such annotations are either
directly present or
indirectly present.
|
Executable |
getDeclaringExecutable()
Return the
Executable which declares this parameter.
|
int |
getModifiers()
Get the modifier flags for this the parameter represented by this
Parameter object.
|
String |
getName()
Returns the name of the parameter.
|
Type |
getParameterizedType()
Returns a
Type object that identifies the parameterized type for the parameter represented by this
Parameter object.
|
Class |
getType()
Returns a
Class object that identifies the declared type for the parameter represented by this
Parameter object.
|
int |
hashCode()
Returns a hash code based on the executable's hash code and the index.
|
boolean |
isImplicit()
Returns
true if this parameter is implicitly declared in source code; returns
false otherwise.
|
boolean |
isNamePresent()
Returns true if the parameter has a name according to the class file; returns false otherwise.
|
boolean |
isSynthetic()
Returns
true if this parameter is neither implicitly nor explicitly declared in source code; returns
false otherwise.
|
boolean |
isVarArgs()
Returns
true if this parameter represents a variable argument list; returns
false otherwise.
|
String |
toString()
Returns a string describing this parameter.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitisAnnotationPresentpublic boolean equals(Objectobj)
equals in class
Object
obj - The object to compare.
Object.hashCode() ,
HashMap
public int hashCode()
hashCode in class
Object
Object.equals(java.lang.Object) ,
System.identityHashCode(java.lang.Object)
public boolean isNamePresent()
public StringtoString()
public ExecutablegetDeclaringExecutable()
Executable which declares this parameter.
Executable declaring this parameter.
public int getModifiers()
Parameter object.
public StringgetName()
public TypegetParameterizedType()
Type object that identifies the parameterized type for the parameter represented by this
Parameter object.
Type object identifying the parameterized type of the parameter represented by this object
public Class<?> getType()
Class object that identifies the declared type for the parameter represented by this
Parameter object.
Class object identifying the declared type of the parameter represented by this object
public AnnotatedTypegetAnnotatedType()
AnnotatedType object representing the use of a type to specify the type of the formal parameter represented by this Parameter
public boolean isImplicit()
true if this parameter is implicitly declared in source code; returns
false otherwise.
public boolean isSynthetic()
true if this parameter is neither implicitly nor explicitly declared in source code; returns
false otherwise.
public boolean isVarArgs()
true if this parameter represents a variable argument list; returns
false otherwise.
true if an only if this parameter represents a variable argument list.
public <T extends Annotation> T getAnnotation(Class <T> annotationClass)
getAnnotation in interface
AnnotatedElement
T - the type of the annotation to query for and return if present
annotationClass - the Class object corresponding to the annotation type
NullPointerException - if the given annotation class is null
public <T extends Annotation> T[] getAnnotationsByType(Class <T> annotationClass)
AnnotatedElement.getAnnotation(Class) is that this method detects if its argument is a
repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.
getAnnotationsByType in interface
AnnotatedElement
T - the type of the annotation to query for and return if present
annotationClass - the Class object corresponding to the annotation type
NullPointerException - if the given annotation class is null
public Annotation[] getDeclaredAnnotations()
getDeclaredAnnotations in interface
AnnotatedElement
public <T extends Annotation> T getDeclaredAnnotation(Class <T> annotationClass)
AnnotatedElement
getDeclaredAnnotation in interface
AnnotatedElement
T - the type of the annotation to query for and return if directly present
annotationClass - the Class object corresponding to the annotation type
NullPointerException - if the given annotation class is null
public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class <T> annotationClass)
AnnotatedElement
AnnotatedElement.getDeclaredAnnotation(Class) is that this method detects if its argument is a
repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation if one is present. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.
getDeclaredAnnotationsByType in interface
AnnotatedElement
T - the type of the annotation to query for and return if directly or indirectly present
annotationClass - the Class object corresponding to the annotation type
NullPointerException - if the given annotation class is null
public Annotation[] getAnnotations()
getAnnotations in interface
AnnotatedElement