@BeanIgnore public final class MethodInfo extends ExecutableInfo implements Comparable<MethodInfo>
Modifier | Constructor and Description |
---|---|
protected |
MethodInfo(ClassInfo declaringClass,
Method m)
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) |
protected <T extends Annotation> |
findAnnotation(Class<T> a)
Searched for the specified annotation.
|
Annotation |
getAnnotation(Class<? extends Annotation>... c)
Returns the first annotation in the specified list 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. |
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 |
getReturnType()
Returns the generic return type of this method as a
ClassInfo object. |
String |
getSignature()
Returns the signature of this method.
|
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(ClassInfo declaringClass,
Method m)
Convenience method for instantiating a
MethodInfo ; |
static MethodInfo |
of(Method m)
Convenience method for instantiating a
MethodInfo ; |
getAnnotation, getDeclaringClass, getExceptionTypes, getFullName, getParam, getParamCount, getParameterAnnotations, getParameterAnnotations, getParams, getParamType, getParamTypes, getRawExceptionTypes, getRawGenericParamType, getRawGenericParamTypes, getRawParameter, getRawParameters, getRawParamType, getRawParamTypes, getShortName, getSimpleName, hasAnnotation, 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)
declaringClass
- The class that declares this method.m
- The method being wrapped.public static MethodInfo of(ClassInfo declaringClass, Method m)
MethodInfo
;declaringClass
- The class that declares this method.m
- The method being wrapped.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 <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 getAnnotation(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
.protected <T extends Annotation> T findAnnotation(Class<T> a)
ExecutableInfo
findAnnotation
in class ExecutableInfo
a
- The annotation to search for.public ClassInfo getReturnType()
ClassInfo
object.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–2019 The Apache Software Foundation. All rights reserved.