AnnotatedElement
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 | Description |
---|---|---|
Set |
accessFlags() |
Returns an unmodifiable set of the access flags for the parameter represented by this object, possibly empty. |
boolean |
equals |
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 |
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 |
Returns annotations that are associated with this element. |
<T extends Annotation> |
getDeclaredAnnotation |
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 |
Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present. |
Executable |
getDeclaringExecutable() |
Returns the Executable declaring this parameter. |
int |
getModifiers() |
Returns the Java language modifiers for the parameter represented by this 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)
public int hashCode()
public boolean isNamePresent()
public String toString()
public Executable getDeclaringExecutable()
Executable
declaring this parameter.Executable
declaring this parameterpublic int getModifiers()
public Set<AccessFlag> accessFlags()
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)
Note that any annotation returned by this method is a declaration annotation.
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. Note that any annotations returned by this method are declaration annotations.
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()
Note that any annotations returned by this method are declaration annotations.
getDeclaredAnnotations
in interface AnnotatedElement
public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass)
Note that any annotation returned by this method is a declaration annotation.
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.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. Note that any annotations returned by this method are declaration annotations.
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()
Note that any annotations returned by this method are declaration annotations.
getAnnotations
in interface AnnotatedElement
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/reflect/Parameter.html