Class Parameter
java.lang.Object
java.lang.reflect.Parameter
- All Implemented Interfaces:
- 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.- Since:
- 1.8
- 
Method SummaryModifier and TypeMethodDescriptionReturns an unmodifiable set of the access flags for the parameter represented by this object, possibly empty.booleanCompares based on the executable and the index.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>
 TgetAnnotation(Class<T> annotationClass) Returns this element's annotation for the specified type if such an annotation is present, else null.Returns annotations that are present on this element.<T extends Annotation>
 T[]getAnnotationsByType(Class<T> annotationClass) Returns annotations that are associated with this element.<T extends Annotation>
 TgetDeclaredAnnotation(Class<T> annotationClass) Returns this element's annotation for the specified type if such an annotation is directly present, else null.Returns annotations that are directly present on this element.<T extends Annotation>
 T[]getDeclaredAnnotationsByType(Class<T> annotationClass) Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present.Returns theExecutabledeclaring this parameter.intReturns the Java language modifiers for the parameter represented by this object.getName()Returns the name of the parameter.Returns aTypeobject that identifies the parameterized type for the parameter represented by thisParameterobject.Class<?> getType()Returns aClassobject that identifies the declared type for the parameter represented by thisParameterobject.inthashCode()Returns a hash code based on the executable's hash code and the index.booleanReturnstrueif this parameter is implicitly declared in source code; returnsfalseotherwise.booleanReturns true if the parameter has a name according to the class file; returns false otherwise.booleanReturnstrueif this parameter is neither implicitly nor explicitly declared in source code; returnsfalseotherwise.booleanReturnstrueif this parameter represents a variable argument list; returnsfalseotherwise.toString()Returns a string describing this parameter.Methods declared in class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods declared in interface java.lang.reflect.AnnotatedElementisAnnotationPresent
- 
Method Details- 
equals
- 
hashCode
- 
isNamePresentpublic 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.- Returns:
- true if and only if the parameter has a name according to the class file.
 
- 
toStringReturns 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.
- 
getDeclaringExecutableReturns theExecutabledeclaring this parameter.- Returns:
- the Executabledeclaring this parameter
 
- 
getModifierspublic int getModifiers()Returns the Java language modifiers for the parameter represented by this object.- Returns:
- the Java language modifiers for the parameter represented by this object
- See Java Language Specification:
- 
8.4.1 Formal Parameters
- See Also:
 
- 
accessFlagsReturns an unmodifiable set of the access flags for the parameter represented by this object, possibly empty.- Returns:
- an unmodifiable set of the access flags for the parameter represented by this object, possibly empty
- See Java Virtual Machine Specification:
- 
4.7.24 The MethodParameters Attribute
- Since:
- 20
- See Also:
 
- 
getNameReturns 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.- Returns:
- The name of the parameter, either provided by the class file or synthesized if the class file does not provide a name.
 
- 
getParameterizedTypeReturns aTypeobject that identifies the parameterized type for the parameter represented by thisParameterobject.- Returns:
- a Typeobject identifying the parameterized type of the parameter represented by this object
 
- 
getTypeReturns aClassobject that identifies the declared type for the parameter represented by thisParameterobject.- Returns:
- a Classobject identifying the declared type of the parameter represented by this object
 
- 
getAnnotatedTypeReturns an AnnotatedType object that represents the use of a type to specify the type of the formal parameter represented by this Parameter.- Returns:
- an AnnotatedTypeobject representing the use of a type to specify the type of the formal parameter represented by this Parameter
 
- 
isImplicitpublic boolean isImplicit()Returnstrueif this parameter is implicitly declared in source code; returnsfalseotherwise.- Returns:
- true if and only if this parameter is implicitly declared as defined by The Java Language Specification.
 
- 
isSyntheticpublic boolean isSynthetic()Returnstrueif this parameter is neither implicitly nor explicitly declared in source code; returnsfalseotherwise.- Returns:
- true if and only if this parameter is a synthetic construct as defined by The Java Language Specification.
- See Java Language Specification:
- 
13.1 The Form of a Binary
- See Also:
 
- 
isVarArgspublic boolean isVarArgs()Returnstrueif this parameter represents a variable argument list; returnsfalseotherwise.- Returns:
- trueif an only if this parameter represents a variable argument list.
 
- 
getAnnotationReturns this element's annotation for the specified type if such an annotation is present, else null.Note that any annotation returned by this method is a declaration annotation. - Specified by:
- getAnnotationin interface- AnnotatedElement
- Type Parameters:
- T- the type of the annotation to query for and return if present
- Parameters:
- annotationClass- the Class object corresponding to the annotation type
- Returns:
- this element's annotation for the specified annotation type if present on this element, else null
- Throws:
- NullPointerException- if the given annotation class is null
 
- 
getAnnotationsByTypeReturns 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 andAnnotatedElement.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. - Specified by:
- getAnnotationsByTypein interface- AnnotatedElement
- Type Parameters:
- T- the type of the annotation to query for and return if present
- Parameters:
- annotationClass- the Class object corresponding to the annotation type
- Returns:
- all this element's annotations for the specified annotation type if associated with this element, else an array of length zero
- Throws:
- NullPointerException- if the given annotation class is null
 
- 
getDeclaredAnnotationsReturns 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.Note that any annotations returned by this method are declaration annotations. - Specified by:
- getDeclaredAnnotationsin interface- AnnotatedElement
- Returns:
- annotations directly present on this element
 
- 
getDeclaredAnnotationReturns 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.)Note that any annotation returned by this method is a declaration annotation. - Specified by:
- getDeclaredAnnotationin interface- AnnotatedElement
- Type Parameters:
- T- the type of the annotation to query for and return if directly present
- Parameters:
- annotationClass- the Class object corresponding to the annotation type
- Returns:
- this element's annotation for the specified annotation type if directly present on this element, else null
- Throws:
- NullPointerException- if the given annotation class is null
 
- 
getDeclaredAnnotationsByTypeReturns 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 andAnnotatedElement.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. - Specified by:
- getDeclaredAnnotationsByTypein interface- AnnotatedElement
- Type Parameters:
- T- the type of the annotation to query for and return if directly or indirectly present
- Parameters:
- annotationClass- the Class object corresponding to the annotation type
- Returns:
- all this element's annotations for the specified annotation type if directly or indirectly present on this element, else an array of length zero
- Throws:
- NullPointerException- if the given annotation class is null
 
- 
getAnnotationsReturns 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.Note that any annotations returned by this method are declaration annotations. - Specified by:
- getAnnotationsin interface- AnnotatedElement
- Returns:
- annotations present on this element
 
 
-