public final class MethodInfo extends java.lang.Object implements AnnotationTarget
Thread-Safety
This class is immutable and can be shared between threads without safe publication.AnnotationTarget.Kind| Modifier and Type | Field and Description |
|---|---|
private ClassInfo |
clazz |
private MethodInternal |
methodInternal |
| Constructor and Description |
|---|
MethodInfo() |
MethodInfo(ClassInfo clazz,
byte[] name,
Type[] parameters,
Type returnType,
short flags) |
MethodInfo(ClassInfo clazz,
MethodInternal methodInternal) |
| 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.
|
java.util.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 |
(package private) Type[] |
copyExceptions() |
(package private) Type[] |
copyParameters() |
static MethodInfo |
create(ClassInfo clazz,
java.lang.String name,
Type[] args,
Type returnType,
short flags)
Construct a new mock Method instance.
|
ClassInfo |
declaringClass()
Returns the class that declared this method
|
java.util.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.
|
(package private) MethodInternal |
methodInternal() |
java.lang.String |
name()
Returns the name of this method
|
java.util.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.
|
(package private) void |
setAnnotations(java.util.List<AnnotationInstance> annotations) |
(package private) void |
setClassInfo(ClassInfo clazz) |
(package private) void |
setExceptions(Type[] exceptions) |
(package private) void |
setMethodInternal(MethodInternal methodInternal) |
(package private) void |
setParameters(Type[] parameters) |
(package private) void |
setReceiverType(Type receiverType) |
(package private) void |
setReturnType(Type returnType) |
(package private) void |
setTypeParameters(Type[] typeParameters) |
java.lang.String |
toString()
Returns a string representation describing this field.
|
(package private) Type[] |
typeParameterArray() |
java.util.List<TypeVariable> |
typeParameters()
Returns the generic type parameters defined by this method.
|
private MethodInternal methodInternal
private ClassInfo clazz
MethodInfo()
MethodInfo(ClassInfo clazz, MethodInternal methodInternal)
public static MethodInfo create(ClassInfo clazz, java.lang.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 java.lang.String name()
public final AnnotationTarget.Kind kind()
AnnotationTargetkind in interface AnnotationTargetpublic final ClassInfo declaringClass()
@Deprecated public final Type[] args()
parameters() method should be used.final Type[] copyParameters()
public final java.util.List<Type> parameters()
public final Type returnType()
public final Type receiverType()
public final java.util.List<Type> exceptions()
final Type[] copyExceptions()
public final java.util.List<TypeVariable> typeParameters()
public final java.util.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 java.lang.String toString()
toString in class java.lang.Objectpublic final ClassInfo asClass()
AnnotationTargetClassInfo if it is of kind CLASSasClass in interface AnnotationTargetpublic final FieldInfo asField()
AnnotationTargetFieldInfo if it is of kind FIELDasField in interface AnnotationTargetpublic final MethodInfo asMethod()
AnnotationTargetMethodInfo if it is of kind METHODasMethod in interface AnnotationTargetpublic final MethodParameterInfo asMethodParameter()
AnnotationTargetMethodParameterInfo if it is of kind METHOD_PARAMETERasMethodParameter in interface AnnotationTargetpublic final TypeTarget asType()
AnnotationTargetTypeTarget if it is of kind TYPEasType in interface AnnotationTargetfinal MethodInternal methodInternal()
final void setMethodInternal(MethodInternal methodInternal)
final void setClassInfo(ClassInfo clazz)
final Type[] typeParameterArray()
void setTypeParameters(Type[] typeParameters)
void setParameters(Type[] parameters)
void setReturnType(Type returnType)
void setExceptions(Type[] exceptions)
void setReceiverType(Type receiverType)
void setAnnotations(java.util.List<AnnotationInstance> annotations)