public final class Method extends Object
| Modifier and Type | Method and Description |
|---|---|
<T extends Annotation> |
getAnnotation(Class<T> annotationClass) |
Annotation |
getDeclaredAnnotation(Class<? extends Annotation> annotationType)
Returns an
Annotation object reflecting the annotation provided, or null of this field doesn't
have such an annotation. |
Annotation[] |
getDeclaredAnnotations()
Returns an array of
Annotation objects reflecting all annotations declared by this field,
or an empty array if there are none. |
Class |
getDeclaringClass()
Returns the Class object representing the class or interface that declares the method.
|
String |
getName()
Returns the name of the method.
|
Class[] |
getParameterTypes()
Returns an array of Class objects that represent the formal parameter types, in declaration order, of the method.
|
Class |
getReturnType()
Returns a Class object that represents the formal return type of the method.
|
Object |
invoke(Object obj,
Object... args)
Invokes the underlying method on the supplied object with the supplied parameters.
|
boolean |
isAbstract()
Return true if the method includes the
abstract modifier. |
boolean |
isAccessible() |
boolean |
isAnnotationPresent(Class<? extends Annotation> annotationType)
Returns true if the field includes an annotation of the provided class type.
|
boolean |
isDefaultAccess()
Return true if the method does not include any of the
private, protected, or public modifiers. |
boolean |
isFinal()
Return true if the method includes the
final modifier. |
boolean |
isNative()
Return true if the method includes the
native modifier. |
boolean |
isPrivate()
Return true if the method includes the
private modifier. |
boolean |
isProtected()
Return true if the method includes the
protected modifier. |
boolean |
isPublic()
Return true if the method includes the
public modifier. |
boolean |
isStatic()
Return true if the method includes the
static modifier. |
boolean |
isVarArgs()
Return true if the method takes a variable number of arguments.
|
void |
setAccessible(boolean accessible) |
public String getName()
public Class getReturnType()
public Class[] getParameterTypes()
public Class getDeclaringClass()
public boolean isAccessible()
public void setAccessible(boolean accessible)
public boolean isAbstract()
abstract modifier.public boolean isDefaultAccess()
private, protected, or public modifiers.public boolean isFinal()
final modifier.public boolean isPrivate()
private modifier.public boolean isProtected()
protected modifier.public boolean isPublic()
public modifier.public boolean isNative()
native modifier.public boolean isStatic()
static modifier.public boolean isVarArgs()
public Object invoke(Object obj, Object... args) throws ReflectionException
ReflectionExceptionpublic <T extends Annotation> T getAnnotation(Class<T> annotationClass)
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
public Annotation[] getDeclaredAnnotations()
Annotation objects reflecting all annotations declared by this field,
or an empty array if there are none. Does not include inherited annotations.public Annotation getDeclaredAnnotation(Class<? extends Annotation> annotationType)
Annotation object reflecting the annotation provided, or null of this field doesn't
have such an annotation. This is a convenience function if the caller knows already which annotation
type he's looking for.Copyright © 2019. All rights reserved.