Class ExecutableInfo
- Direct Known Subclasses:
ConstructorInfo
,MethodInfo
-
Constructor Summary
ModifierConstructorDescriptionprotected
ExecutableInfo
(ClassInfo declaringClass, Executable e) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionAttempts to callx.setAccessible(
and quietly ignores security exceptions.true )forEachParam
(Predicate<ParamInfo> filter, Consumer<ParamInfo> action) Performs an action on every parameter that matches the specified filter.final <A extends Annotation>
ExecutableInfoforEachParameterAnnotation
(int index, Class<A> type, Predicate<A> predicate, Consumer<A> consumer) Performs an action on all matching parameter annotations at the specified parameter index.final int
fuzzyArgsMatch
(Class<?>... argTypes) Returns how well this method matches the specified arg types.final int
fuzzyArgsMatch
(Object... argTypes) Returns how well this method matches the specified arg types.final int
fuzzyArgsMatch
(ClassInfo... argTypes) Returns how well this method matches the specified arg types.final ClassInfo
Returns metadata about the class that declared this method or constructor.Returns the exception types on this executable.final String
Returns the full name of this executable.final ParamInfo
getParam
(int index) Returns parameter information at the specified index.final int
Returns the number of parameters in this executable.Returns the parameters defined on this executable.final ClassInfo
getParamType
(int index) Returns the parameter type of the parameter at the specified index.Returns the parameter types on this executable.final Type
getRawGenericParamType
(int index) Returns the raw generic parameter type of the parameter at the specified index.Returns the raw generic parameter types on this executable.final Parameter
getRawParameter
(int index) Returns the rawParameter
object that represents the parameter at the specified index.Returns an array of rawParameter
objects that represent all the parameters to the underlying executable represented by this object.final Class<?>
getRawParamType
(int index) Returns the raw parameter type of the parameter at the specified index.Returns the raw parameter types on this executable.final String
Returns the short name of this executable.final String
Returns the simple name of the underlying method.final boolean
hasFuzzyParamTypes
(Class<?>... args) Returnstrue if this method has at most only this arguments in any order.final boolean
hasFuzzyParamTypes
(ClassInfo... args) Returnstrue if this method has at most only this arguments in any order.final boolean
hasMatchingParamTypes
(Class<?>... args) Returnstrue if this method has the specified argument parent classes.final boolean
hasMatchingParamTypes
(ClassInfo... args) Returnstrue if this method has the specified argument parent classes.final boolean
Returnstrue if this method has this name.final boolean
Returnstrue if this method has a name in the specified list.final boolean
Returnstrue if this method has a name in the specified set.final boolean
Returnstrue if this executable has no parameters.final boolean
hasNumParams
(int number) Returnstrue if this executable has this number of arguments.final boolean
Returnstrue if this executable has at least one parameter.final boolean
hasParamTypes
(Class<?>... args) Returnstrue if this method has the specified arguments.final boolean
hasParamTypes
(ClassInfo... args) Returnstrue if this method has the specified arguments.final boolean
is
(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this field.final boolean
Returnstrue if this method is abstract.final boolean
isAll
(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this method.final boolean
isAny
(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this method.final boolean
Returnstrue if this executable represents aConstructor
.final boolean
Returnstrue if this method has the@Deprecated
annotation on it.final boolean
Returnstrue if this method is not abstract.final boolean
Returnstrue if this method doesn't have the@Deprecated
annotation on it.final boolean
Returnstrue if this method is not protected.final boolean
Returnstrue if this method is not public.final boolean
Returnstrue if this method is not static.final boolean
Returnstrue if this method is protected.final boolean
isPublic()
Returnstrue if this method is public.final boolean
isStatic()
Returnstrue if this method is static.final boolean
Identifies if the specified visibility matches this method.final boolean
Attempts to callx.setAccessible(
and quietly ignores security exceptions.true )toString()
-
Constructor Details
-
ExecutableInfo
Constructor.- Parameters:
declaringClass
- The class that declares this method or constructor.e
- The constructor or method that this info represents.
-
-
Method Details
-
getDeclaringClass
Returns metadata about the class that declared this method or constructor.- Returns:
- Metadata about the class that declared this method or constructor.
-
isConstructor
Returnstrue if this executable represents aConstructor
.- Returns:
true if this executable represents aConstructor
and can be cast toConstructorInfo
.false if this executable represents aMethod
and can be cast toMethodInfo
.
-
getParamCount
Returns the number of parameters in this executable.Same as calling
Executable.getParameterCount()
.- Returns:
- The number of parameters in this executable.
-
hasParams
Returnstrue if this executable has at least one parameter.Same as calling
Executable.getParameterCount()
and comparing with zero.- Returns:
true if this executable has at least one parameter.
-
hasNoParams
Returnstrue if this executable has no parameters.Same as calling
Executable.getParameterCount()
and comparing with zero.- Returns:
true if this executable has no parameters.
-
hasNumParams
Returnstrue if this executable has this number of arguments.Same as calling
Executable.getParameterCount()
and comparing the count.- Parameters:
number
- The number of expected arguments.- Returns:
true if this executable has this number of arguments.
-
getParams
Returns the parameters defined on this executable.Same as calling
Executable.getParameters()
but wraps the results- Returns:
- An array of parameter information, never
null .
-
forEachParam
Performs an action on every parameter that matches the specified filter.- Parameters:
filter
- The filter, can benull .action
- The action to perform.- Returns:
- This object.
-
getParam
Returns parameter information at the specified index.- Parameters:
index
- The parameter index.- Returns:
- The parameter information, never
null .
-
getParamTypes
Returns the parameter types on this executable.- Returns:
- The parameter types on this executable.
-
getParamType
Returns the parameter type of the parameter at the specified index.- Parameters:
index
- The parameter index.- Returns:
- The parameter type of the parameter at the specified index.
-
getRawParamTypes
Returns the raw parameter types on this executable.- Returns:
- The raw parameter types on this executable.
-
getRawParamType
Returns the raw parameter type of the parameter at the specified index.- Parameters:
index
- The parameter index.- Returns:
- The raw parameter type of the parameter at the specified index.
-
getRawGenericParamTypes
Returns the raw generic parameter types on this executable.- Returns:
- The raw generic parameter types on this executable.
-
getRawGenericParamType
Returns the raw generic parameter type of the parameter at the specified index.- Parameters:
index
- The parameter index.- Returns:
- The raw generic parameter type of the parameter at the specified index.
-
getRawParameters
Returns an array of rawParameter
objects that represent all the parameters to the underlying executable represented by this object.- Returns:
- An array of raw
Parameter
objects, or an empty array if executable has no parameters. - See Also:
-
getRawParameter
Returns the rawParameter
object that represents the parameter at the specified index.- Parameters:
index
- The parameter index.- Returns:
- The raw
Parameter
object that represents the parameter at the specified index. - See Also:
-
forEachParameterAnnotation
public final <A extends Annotation> ExecutableInfo forEachParameterAnnotation(int index, Class<A> type, Predicate<A> predicate, Consumer<A> consumer) Performs an action on all matching parameter annotations at the specified parameter index.- Type Parameters:
A
- The annotation type.- Parameters:
index
- The parameter index.type
- The annotation type.predicate
- The predicate.consumer
- The consumer.- Returns:
- This object.
-
getExceptionTypes
Returns the exception types on this executable.- Returns:
- The exception types on this executable.
-
isAll
Returnstrue if all specified flags are applicable to this method.- Parameters:
flags
- The flags to test for.- Returns:
true if all specified flags are applicable to this method.
-
is
Returnstrue if all specified flags are applicable to this field.- Parameters:
flags
- The flags to test for.- Returns:
true if all specified flags are applicable to this field.
-
isAny
Returnstrue if all specified flags are applicable to this method.- Parameters:
flags
- The flags to test for.- Returns:
true if all specified flags are applicable to this method.
-
hasParamTypes
Returnstrue if this method has the specified arguments.- Parameters:
args
- The arguments to test for.- Returns:
true if this method has this arguments in the exact order.
-
hasParamTypes
Returnstrue if this method has the specified arguments.- Parameters:
args
- The arguments to test for.- Returns:
true if this method has this arguments in the exact order.
-
hasMatchingParamTypes
Returnstrue if this method has the specified argument parent classes.- Parameters:
args
- The arguments to test for.- Returns:
true if this method has this arguments in the exact order.
-
hasMatchingParamTypes
Returnstrue if this method has the specified argument parent classes.- Parameters:
args
- The arguments to test for.- Returns:
true if this method has this arguments in the exact order.
-
hasFuzzyParamTypes
Returnstrue if this method has at most only this arguments in any order.- Parameters:
args
- The arguments to test for.- Returns:
true if this method has at most only this arguments in any order.
-
fuzzyArgsMatch
Returns how well this method matches the specified arg types.The number returned is the number of method arguments that match the passed in arg types.
Returns-1 if the method cannot take in one or more of the specified arguments.- Parameters:
argTypes
- The arg types to check against.- Returns:
- How many parameters match or
-1 if method cannot handle one or more of the arguments.
-
fuzzyArgsMatch
Returns how well this method matches the specified arg types.The number returned is the number of method arguments that match the passed in arg types.
Returns-1 if the method cannot take in one or more of the specified arguments.- Parameters:
argTypes
- The arg types to check against.- Returns:
- How many parameters match or
-1 if method cannot handle one or more of the arguments.
-
hasFuzzyParamTypes
Returnstrue if this method has at most only this arguments in any order.- Parameters:
args
- The arguments to test for.- Returns:
true if this method has at most only this arguments in any order.
-
fuzzyArgsMatch
Returns how well this method matches the specified arg types.The number returned is the number of method arguments that match the passed in arg types.
Returns-1 if the method cannot take in one or more of the specified arguments.- Parameters:
argTypes
- The arg types to check against.- Returns:
- How many parameters match or
-1 if method cannot handle one or more of the arguments.
-
isDeprecated
Returnstrue if this method has the@Deprecated
annotation on it.- Returns:
true if this method has the@Deprecated
annotation on it.
-
isNotDeprecated
Returnstrue if this method doesn't have the@Deprecated
annotation on it.- Returns:
true if this method doesn't have the@Deprecated
annotation on it.
-
isAbstract
Returnstrue if this method is abstract.- Returns:
true if this method is abstract.
-
isNotAbstract
Returnstrue if this method is not abstract.- Returns:
true if this method is not abstract.
-
isPublic
Returnstrue if this method is public.- Returns:
true if this method is public.
-
isNotPublic
Returnstrue if this method is not public.- Returns:
true if this method is not public.
-
isProtected
Returnstrue if this method is protected.- Returns:
true if this method is protected.
-
isNotProtected
Returnstrue if this method is not protected.- Returns:
true if this method is not protected.
-
isStatic
Returnstrue if this method is static.- Returns:
true if this method is static.
-
isNotStatic
Returnstrue if this method is not static.- Returns:
true if this method is not static.
-
accessible
Attempts to callx.setAccessible(
and quietly ignores security exceptions.true )- Returns:
- This object.
-
setAccessible
Attempts to callx.setAccessible(
and quietly ignores security exceptions.true )- Returns:
true if call was successful.
-
isVisible
Identifies if the specified visibility matches this method.- Parameters:
v
- The visibility to validate against.- Returns:
true if this visibility matches the modifier attribute of this method.
-
hasName
Returnstrue if this method has this name.- Parameters:
name
- The name to test for.- Returns:
true if this method has this name.
-
hasName
Returnstrue if this method has a name in the specified list.- Parameters:
names
- The names to test for.- Returns:
true if this method has one of the names.
-
hasName
Returnstrue if this method has a name in the specified set.- Parameters:
names
- The names to test for.- Returns:
true if this method has one of the names.
-
getFullName
Returns the full name of this executable.Examples:
"com.foo.MyClass.get(java.util.String)" - Method."com.foo.MyClass(java.util.String)" - Constructor.
- Returns:
- The underlying executable name.
-
getShortName
Returns the short name of this executable.Examples:
"MyClass.get(String)" - Method."MyClass(String)" - Constructor.
- Returns:
- The underlying executable name.
-
getSimpleName
Returns the simple name of the underlying method.- Returns:
- The simple name of the underlying method;
-
toString
-