public final class Parameter extends Object implements AnnotatedElement
Information about method parameters. A Parameter
provides information about method parameters, including its name and modifiers. It also provides an alternate means of obtaining attributes for the parameter.
public boolean equals(Object obj)
Compares based on the executable and the index.
equals
in class Object
obj
- The object to compare.Object.hashCode()
, HashMap
public int hashCode()
Returns a hash code based on the executable's hash code and the index.
hashCode
in class Object
Object.equals(java.lang.Object)
, System.identityHashCode(java.lang.Object)
public boolean isNamePresent()
Returns true if the parameter has a name according to the class file; returns false otherwise. Whether a parameter has a name is determined by the MethodParameters attribute of the method which declares the parameter.
public String toString()
Returns a string describing this parameter. The format is the modifiers for the parameter, if any, in canonical order as recommended by The Java™ Language Specification, followed by the fully- qualified type of the parameter (excluding the last [] if the parameter is variable arity), followed by "..." if the parameter is variable arity, followed by a space, followed by the name of the parameter.
toString
in class Object
public Executable getDeclaringExecutable()
Return the Executable
which declares this parameter.
Executable
declaring this parameter.public int getModifiers()
Get the modifier flags for this the parameter represented by this Parameter
object.
public String getName()
Returns the name of the parameter. If the parameter's name is present, then this method returns the name provided by the class file. Otherwise, this method synthesizes a name of the form argN, where N is the index of the parameter in the descriptor of the method which declares the parameter.
public Type getParameterizedType()
Returns a 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()
Returns a 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()
Returns an AnnotatedType object that represents the use of a type to specify the type of the formal parameter represented by this Parameter.
AnnotatedType
object representing the use of a type to specify the type of the formal parameter represented by this Parameterpublic boolean isImplicit()
Returns true
if this parameter is implicitly declared in source code; returns false
otherwise.
public boolean isSynthetic()
Returns true
if this parameter is neither implicitly nor explicitly declared in source code; returns false
otherwise.
public boolean isVarArgs()
Returns 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)
Returns this element's annotation for the specified type if such an annotation is present, else null.
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)
Returns annotations that are associated with this element. If there are no annotations associated with this element, the return value is an array of length 0. The difference between this method and 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()
Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.
getDeclaredAnnotations
in interface AnnotatedElement
public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass)
Description copied from interface: AnnotatedElement
Returns this element's annotation for the specified type if such an annotation is directly present, else null. This method ignores inherited annotations. (Returns null if no annotations are directly present on this element.)
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)
Description copied from interface: AnnotatedElement
Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present. This method ignores inherited annotations. If there are no specified annotations directly or indirectly present on this element, the return value is an array of length 0. The difference between this method and 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()
Returns annotations that are present on this element. If there are no annotations present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.
getAnnotations
in interface AnnotatedElement
© 1993–2017, 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.