@BeanIgnore public final class MethodInfo extends ExecutableInfo implements Comparable<MethodInfo>
Modifier | Constructor and Description |
---|---|
protected |
MethodInfo(ClassInfo declaringClass,
Method m,
Method rm)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<T extends Annotation> |
appendAnnotations(List<T> l,
Class<T> a)
Finds and appends the specified annotation on the specified method and methods on superclasses/interfaces to the specified
list.
|
<T extends Annotation> |
appendAnnotationsParentFirst(List<T> l,
Class<T> a)
Finds and appends the specified annotation on the specified class and superclasses/interfaces to the specified
list.
|
boolean |
argsOnlyOfType(Class<?>... args)
Returns
|
int |
compareTo(MethodInfo o) |
<T extends Annotation> |
getAnnotation(Class<T> a)
Finds the annotation of the specified type defined on this method.
|
<T extends Annotation> |
getAnnotation(Class<T> a,
MetaProvider mp)
Finds the annotation of the specified type defined on this method.
|
AnnotationList |
getAnnotationList(Predicate<AnnotationInfo<?>> filter)
Constructs an
AnnotationList of all annotations found on this method. |
AnnotationList |
getAnnotationListMethodOnlyParentFirst(Predicate<AnnotationInfo<?>> filter)
Same as
getAnnotationListParentFirst(Predicate) except only returns annotations defined on methods. |
AnnotationList |
getAnnotationListParentFirst(Predicate<AnnotationInfo<?>> filter)
Constructs an
AnnotationList of all annotations found on this method. |
<T extends Annotation> |
getAnnotations(Class<T> a)
Returns all annotations of the specified type defined on the specified method.
|
<T extends Annotation> |
getAnnotationsParentFirst(Class<T> a)
Identical to
getAnnotations(Class) but returns the list in reverse (parent-to-child) order. |
Annotation |
getAnyAnnotation(Class<? extends Annotation>... c)
Returns the first annotation in the specified list on this method.
|
List<Method> |
getMatching()
Finds all declared methods with the same name and arguments on all superclasses and interfaces.
|
Iterable<Method> |
getMatchingParentFirst()
Convenience method for retrieving values in
getMatching() in parent-to-child order. |
String |
getPropertyName()
Returns the bean property name if this is a getter or setter.
|
ClassInfo |
getResolvedReturnType()
Returns the generic return type of this method as a
ClassInfo object. |
ClassInfo |
getReturnType()
Returns the generic return type of this method as a
ClassInfo object. |
String |
getSignature()
Returns the signature of this method.
|
boolean |
hasAnnotation(Class<? extends Annotation> a)
Returns
|
boolean |
hasConfigAnnotations()
Returns
PropertyStoreApply . |
boolean |
hasReturnType(Class<?> c)
Returns
|
boolean |
hasReturnType(ClassInfo ci)
Returns
|
boolean |
hasReturnTypeParent(Class<?> c)
Returns
|
boolean |
hasReturnTypeParent(ClassInfo ci)
Returns
|
Method |
inner()
Returns the wrapped method.
|
<T> T |
invoke(Object obj,
Object... args)
Shortcut for calling the invoke method on the underlying method.
|
Object |
invokeFuzzy(Object pojo,
Object... args)
Invokes the specified method using fuzzy-arg matching.
|
boolean |
isBridge()
Returns
|
static MethodInfo |
of(Class<?> declaringClass,
Method m,
Method rm)
Convenience method for instantiating a
MethodInfo ; |
static MethodInfo |
of(ClassInfo declaringClass,
Method m,
Method rm)
Convenience method for instantiating a
MethodInfo ; |
static MethodInfo |
of(Method m)
Convenience method for instantiating a
MethodInfo ; |
getDeclaringClass, getExceptionTypes, getFullName, getParam, getParamCount, getParameterAnnotations, getParameterAnnotations, getParams, getParamType, getParamTypes, getRawExceptionTypes, getRawGenericParamType, getRawGenericParamTypes, getRawParameter, getRawParameters, getRawParamType, getRawParamTypes, getShortName, getSimpleName, hasFuzzyParamTypes, hasFuzzyParamTypes, hasName, hasName, hasName, hasNoParams, hasNumParams, hasParams, hasParamTypeParents, hasParamTypeParents, hasParamTypes, hasParamTypes, isAbstract, isAll, isAny, isConstructor, isDeprecated, isNotAbstract, isNotDeprecated, isNotPublic, isNotStatic, isPublic, isStatic, isVisible, setAccessible, toString
protected MethodInfo(ClassInfo declaringClass, Method m, Method rm)
declaringClass
- The class that declares this method.m
- The method being wrapped.rm
- The "real" method if the method above is defined against a CGLIB proxy.public static MethodInfo of(ClassInfo declaringClass, Method m, Method rm)
MethodInfo
;declaringClass
- The class that declares this method.m
- The method being wrapped.rm
- The "real" method if the method above is defined against a CGLIB proxy.MethodInfo
object, or public static MethodInfo of(Class<?> declaringClass, Method m, Method rm)
MethodInfo
;declaringClass
- The class that declares this method.m
- The method being wrapped.rm
- The "real" method if the method above is defined against a CGLIB proxy.MethodInfo
object, or public static MethodInfo of(Method m)
MethodInfo
;m
- The method being wrapped.MethodInfo
object, or public List<Method> getMatching()
public Iterable<Method> getMatchingParentFirst()
getMatching()
in parent-to-child order.public final <T extends Annotation> T getAnnotation(Class<T> a)
If this is a method and the annotation cannot be found on the immediate method, searches methods with the same
signature on the parent classes or interfaces.
The search is performed in child-to-parent order.
a
- The annotation to search for.public final <T extends Annotation> T getAnnotation(Class<T> a, MetaProvider mp)
Searches all methods with the same signature on the parent classes or interfaces and the return type on the method.
a
- The annotation to search for.mp
- The meta provider for looking up annotations on classes/methods/fields.public final boolean hasAnnotation(Class<? extends Annotation> a)
a
- The annotation to check for.public <T extends Annotation> List<T> getAnnotations(Class<T> a)
Searches all methods with the same signature on the parent classes or interfaces and the return type on the method.
a
- The annotation to search for.public <T extends Annotation> List<T> getAnnotationsParentFirst(Class<T> a)
getAnnotations(Class)
but returns the list in reverse (parent-to-child) order.a
- The annotation to search for.public <T extends Annotation> List<T> appendAnnotations(List<T> l, Class<T> a)
Results are ordered in child-to-parent order.
l
- The list of annotations.a
- The annotation.public <T extends Annotation> List<T> appendAnnotationsParentFirst(List<T> l, Class<T> a)
l
- The list of annotations.a
- The annotation.@SafeVarargs public final Annotation getAnyAnnotation(Class<? extends Annotation>... c)
c
- The annotations that cannot be present on the method.public AnnotationList getAnnotationList(Predicate<AnnotationInfo<?>> filter)
AnnotationList
of all annotations found on this method.
Annotations are appended in the following orders:
filter
- Optional filter to apply to limit which annotations are added to the list.
AnnotationList
object on every call.public AnnotationList getAnnotationListParentFirst(Predicate<AnnotationInfo<?>> filter)
AnnotationList
of all annotations found on this method.
Annotations are appended in the following orders:
filter
- Optional filter to apply to limit which annotations are added to the list.
AnnotationList
object on every call.public AnnotationList getAnnotationListMethodOnlyParentFirst(Predicate<AnnotationInfo<?>> filter)
getAnnotationListParentFirst(Predicate)
except only returns annotations defined on methods.filter
- Optional filter to apply to limit which annotations are added to the list.
AnnotationList
object on every call.public boolean hasConfigAnnotations()
PropertyStoreApply
.PropertyStoreApply
.public ClassInfo getReturnType()
ClassInfo
object.public ClassInfo getResolvedReturnType()
ClassInfo
object.
Unwraps the type if it's a Value
.
public boolean hasReturnType(Class<?> c)
c
- The return type to test for.public boolean hasReturnType(ClassInfo ci)
ci
- The return type to test for.public boolean hasReturnTypeParent(Class<?> c)
c
- The return type to test for.public boolean hasReturnTypeParent(ClassInfo ci)
ci
- The return type to test for.public <T> T invoke(Object obj, Object... args) throws ExecutableException
obj
- the object the underlying method is invoked from.args
- the arguments used for the method callExecutableException
- Exception occurred on invoked constructor/method/field.public Object invokeFuzzy(Object pojo, Object... args) throws ExecutableException
Arguments will be matched to the parameters based on the parameter types.
Arguments can be in any order.
Extra arguments will be ignored.
Missing arguments will be left
Note that this only works for methods that have distinguishable argument types.
It's not going to work on methods with generic argument types like
pojo
- The POJO the method is being called on.
args
- The arguments to pass to the method.ExecutableException
- Exception occurred on invoked constructor/method/field.public String getSignature()
For no-arg methods, the signature will be a simple string such as
public String getPropertyName()
public boolean argsOnlyOfType(Class<?>... args)
args
- The valid class types (exact) for the arguments.public boolean isBridge()
public int compareTo(MethodInfo o)
compareTo
in interface Comparable<MethodInfo>
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.