public final class MethodInfo extends Object implements AnnotationTarget
Thread-Safety
This class is immutable and can be shared between threads without safe publication.AnnotationTarget.Kind
Modifier and Type | Method and Description |
---|---|
AnnotationInstance |
annotation(DotName name)
Retrieves an annotation instance declared on this method, it parameters, or any type within the signature
of the method, by the name of the annotation.
|
List<AnnotationInstance> |
annotations()
Returns the annotation instances declared on this method.
|
Type[] |
args()
Deprecated.
|
ClassInfo |
asClass()
Casts and returns this target as a
ClassInfo if it is of kind CLASS |
FieldInfo |
asField()
Casts and returns this target as a
FieldInfo if it is of kind FIELD |
MethodInfo |
asMethod()
Casts and returns this target as a
MethodInfo if it is of kind METHOD |
MethodParameterInfo |
asMethodParameter()
Casts and returns this target as a
MethodParameterInfo if it is of kind METHOD_PARAMETER |
TypeTarget |
asType()
Casts and returns this target as a
TypeTarget if it is of kind TYPE |
static MethodInfo |
create(ClassInfo clazz,
String name,
Type[] args,
Type returnType,
short flags)
Construct a new mock Method instance.
|
ClassInfo |
declaringClass()
Returns the class that declared this method
|
List<Type> |
exceptions()
Returns the list of throwable classes declared to be thrown by this method.
|
short |
flags()
Returns the access fields of this method.
|
boolean |
hasAnnotation(DotName name)
Returns whether or not the annotation instance with the given name occurs on this method, its parameters
or its signature
|
AnnotationTarget.Kind |
kind()
Returns the kind of object this target represents.
|
String |
name()
Returns the name of this method
|
List<Type> |
parameters()
Returns a list containing the types of all parameters declared on this method, in parameter order.
|
Type |
receiverType()
Returns the receiver type of this method (a declaration of the "this" reference), if specified.
|
Type |
returnType()
Returns this method's return parameter type.
|
String |
toString()
Returns a string representation describing this field.
|
List<TypeVariable> |
typeParameters()
Returns the generic type parameters defined by this method.
|
public static MethodInfo create(ClassInfo clazz, String name, Type[] args, Type returnType, short flags)
clazz
- the class declaring the fieldname
- the name of the fieldargs
- a read only array containing the types of each parameter in parameter orderreturnType
- the return value typeflags
- the method attributespublic final String name()
public final AnnotationTarget.Kind kind()
AnnotationTarget
kind
in interface AnnotationTarget
public final ClassInfo declaringClass()
@Deprecated public final Type[] args()
parameters()
method should be used.public final List<Type> parameters()
public final Type returnType()
public final Type receiverType()
public final List<Type> exceptions()
public final List<TypeVariable> typeParameters()
public final List<AnnotationInstance> annotations()
target()
of the returned annotation instances may be used to determine the
exact location of ths respective annotation instance.
The following is a non-exhaustive list of examples of annotations returned by this method:
@MyMethodAnnotation public void foo() {...} public void foo(@MyParamAnnotation int param) {...} public void foo(List<@MyTypeAnnotation> list) {...} public <@AnotherTypeAnnotation T> void foo(T t) {...}
public final AnnotationInstance annotation(DotName name)
The following is a non-exhaustive list of examples of annotations returned by this method:
@MyMethodAnnotation public void foo() {...} public void foo(@MyParamAnnotation int param) {...} public void foo(List<@MyTypeAnnotation> list) {...} public <@AnotherTypeAnnotation T> void foo(T t) {...}
name
- the name of the annotation to locate within the methodpublic final boolean hasAnnotation(DotName name)
name
- the name of the annotation to look forannotations()
,
annotation(DotName)
public final short flags()
Modifier
can be used on this value.public String toString()
public final ClassInfo asClass()
AnnotationTarget
ClassInfo
if it is of kind CLASS
asClass
in interface AnnotationTarget
public final FieldInfo asField()
AnnotationTarget
FieldInfo
if it is of kind FIELD
asField
in interface AnnotationTarget
public final MethodInfo asMethod()
AnnotationTarget
MethodInfo
if it is of kind METHOD
asMethod
in interface AnnotationTarget
public final MethodParameterInfo asMethodParameter()
AnnotationTarget
MethodParameterInfo
if it is of kind METHOD_PARAMETER
asMethodParameter
in interface AnnotationTarget
public final TypeTarget asType()
AnnotationTarget
TypeTarget
if it is of kind TYPE
asType
in interface AnnotationTarget
Copyright © 2018 JBoss by Red Hat. All rights reserved.