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 |
(package private) static java.lang.String[] |
EMPTY_PARAMETER_NAMES |
private MethodInternal |
methodInternal |
Constructor and Description |
---|
MethodInfo() |
MethodInfo(ClassInfo clazz,
byte[] name,
byte[][] parameterNames,
Type[] parameters,
Type returnType,
short flags) |
MethodInfo(ClassInfo clazz,
byte[] name,
byte[][] parameterNames,
Type[] parameters,
Type returnType,
short flags,
Type[] typeParameters,
Type[] exceptions) |
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,
java.lang.String[] parameterNames,
Type[] args,
Type returnType,
short flags,
TypeVariable[] typeParameters,
Type[] exceptions)
Construct a new mock Method instance.
|
static MethodInfo |
create(ClassInfo clazz,
java.lang.String name,
Type[] args,
Type returnType,
short flags)
Construct a new mock Method instance.
|
static MethodInfo |
create(ClassInfo clazz,
java.lang.String name,
Type[] args,
Type returnType,
short flags,
TypeVariable[] typeParameters,
Type[] exceptions)
Construct a new mock Method instance.
|
ClassInfo |
declaringClass()
Returns the class that declared this method
|
AnnotationValue |
defaultValue()
Returns the default annotation value if this method represents an annotation member with a default value.
|
boolean |
equals(java.lang.Object o) |
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
|
int |
hashCode() |
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.lang.String |
parameterName(int i)
Returns the name of the given parameter.
|
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 |
setDefaultValue(AnnotationValue defaultValue) |
(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.
|
static final java.lang.String[] EMPTY_PARAMETER_NAMES
private MethodInternal methodInternal
private ClassInfo clazz
MethodInfo()
MethodInfo(ClassInfo clazz, MethodInternal methodInternal)
MethodInfo(ClassInfo clazz, byte[] name, byte[][] parameterNames, Type[] parameters, Type returnType, short flags)
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 static MethodInfo create(ClassInfo clazz, java.lang.String name, Type[] args, Type returnType, short flags, TypeVariable[] typeParameters, Type[] exceptions)
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 attributestypeParameters
- the generic type parameters for this methodexceptions
- the exceptions declared as thrown by this methodpublic static MethodInfo create(ClassInfo clazz, java.lang.String name, java.lang.String[] parameterNames, Type[] args, Type returnType, short flags, TypeVariable[] typeParameters, Type[] exceptions)
clazz
- the class declaring the fieldname
- the name of the fieldparameterNames
- the names of the method parameterargs
- a read only array containing the types of each parameter in parameter orderreturnType
- the return value typeflags
- the method attributestypeParameters
- the generic type parameters for this methodexceptions
- the exceptions declared as thrown by this methodpublic final java.lang.String name()
public final java.lang.String parameterName(int i)
i
- the parameter indexpublic final AnnotationTarget.Kind kind()
AnnotationTarget
kind
in interface AnnotationTarget
public 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 AnnotationValue defaultValue()
public final short flags()
Modifier
can be used on this value.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
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
final 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)
void setDefaultValue(AnnotationValue defaultValue)