public final class Parameter extends Object implements 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 obj)
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<T> annotationClass)
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<T> annotationClass)
Returns annotations that are associated with this element.
|
<T extends Annotation> |
getDeclaredAnnotation(Class<T> annotationClass)
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<T> annotationClass)
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, wait
isAnnotationPresent
public boolean equals(Object obj)
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 String toString()
public Executable getDeclaringExecutable()
Executable
which declares this parameter.Executable
declaring this parameter.public int getModifiers()
Parameter
object.public String getName()
public Type getParameterizedType()
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 objectpublic 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 objectpublic AnnotatedType getAnnotatedType()
AnnotatedType
object representing the use of a type
to specify the type of the formal parameter represented by this
Parameterpublic 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 presentannotationClass
- the Class object corresponding to the
annotation typeNullPointerException
- if the given annotation class is nullpublic <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 presentannotationClass
- the Class object corresponding to the
annotation typeNullPointerException
- if the given annotation class is nullpublic 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 presentannotationClass
- the Class object corresponding to the
annotation typeNullPointerException
- if the given annotation class is nullpublic <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 presentannotationClass
- the Class object corresponding to the
annotation typeNullPointerException
- if the given annotation class is nullpublic Annotation[] getAnnotations()
getAnnotations
in interface 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, 2018, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.