Package io.microsphere.reflect
Class MethodDefinition
- java.lang.Object
-
- io.microsphere.reflect.ReflectiveDefinition
-
- io.microsphere.reflect.MemberDefinition<E>
-
- io.microsphere.reflect.ExecutableDefinition<java.lang.reflect.Method>
-
- io.microsphere.reflect.MethodDefinition
-
- All Implemented Interfaces:
java.io.Serializable
public class MethodDefinition extends ExecutableDefinition<java.lang.reflect.Method>
The definition class of JavaMethod
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
Method
,Version
, Serialized Form
-
-
Field Summary
-
Fields inherited from class io.microsphere.reflect.ExecutableDefinition
parameterClassNames
-
Fields inherited from class io.microsphere.reflect.MemberDefinition
name
-
Fields inherited from class io.microsphere.reflect.ReflectiveDefinition
className, deprecation, since
-
-
Constructor Summary
Constructors Constructor Description MethodDefinition(Version since, Deprecation deprecation, java.lang.String declaredClassName, java.lang.String methodName, java.lang.String... parameterClassNames)
MethodDefinition(Version since, java.lang.String declaredClassName, java.lang.String methodName, java.lang.String... parameterClassNames)
MethodDefinition(java.lang.String since, Deprecation deprecation, java.lang.String declaredClassName, java.lang.String methodName, java.lang.String... parameterClassNames)
MethodDefinition(java.lang.String since, java.lang.String declaredClassName, java.lang.String methodName, java.lang.String... parameterClassNames)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.reflect.Method
getMethod()
The resolved methodjava.lang.String
getMethodName()
The method name<R> R
invoke(java.lang.Object instance, java.lang.Object... args)
Invokes the underlying method represented by thisMethod
object, on the specified object with the specified parameters.protected java.lang.reflect.Method
resolveMember()
Resolve themember
instancejava.lang.String
toString()
-
Methods inherited from class io.microsphere.reflect.ExecutableDefinition
equals, getParameterClassNames, getParameterTypes, hashCode, resolveParameterTypes
-
Methods inherited from class io.microsphere.reflect.MemberDefinition
getDeclaredClass, getDeclaredClassName, getMember, getName, isPresent
-
Methods inherited from class io.microsphere.reflect.ReflectiveDefinition
getClassName, getDeprecation, getResolvedClass, getSince, isDeprecated
-
-
-
-
Constructor Detail
-
MethodDefinition
public MethodDefinition(java.lang.String since, java.lang.String declaredClassName, java.lang.String methodName, java.lang.String... parameterClassNames)
- Parameters:
since
- the 'since' versiondeclaredClassName
- The declared class name of the methodmethodName
- the method nameparameterClassNames
- the parameter types
-
MethodDefinition
public MethodDefinition(java.lang.String since, Deprecation deprecation, java.lang.String declaredClassName, java.lang.String methodName, java.lang.String... parameterClassNames)
- Parameters:
since
- the 'since' versiondeprecation
- the deprecationdeclaredClassName
- The declared class name of the methodmethodName
- the method nameparameterClassNames
- the parameter class names
-
MethodDefinition
public MethodDefinition(Version since, java.lang.String declaredClassName, java.lang.String methodName, java.lang.String... parameterClassNames)
- Parameters:
since
- the 'since' versiondeclaredClassName
- The declared class name of the methodmethodName
- the method nameparameterClassNames
- the parameter types
-
MethodDefinition
public MethodDefinition(Version since, Deprecation deprecation, java.lang.String declaredClassName, java.lang.String methodName, java.lang.String... parameterClassNames)
- Parameters:
since
- the 'since' versiondeprecation
- the deprecationdeclaredClassName
- The declared class name of the methodmethodName
- the method nameparameterClassNames
- the parameter class names
-
-
Method Detail
-
getMethodName
@Nonnull public java.lang.String getMethodName()
The method name- Returns:
- non-null
-
getMethod
@Nullable public java.lang.reflect.Method getMethod()
The resolved method- Returns:
null
if not resolved
-
resolveMember
protected java.lang.reflect.Method resolveMember()
Description copied from class:MemberDefinition
Resolve themember
instance- Specified by:
resolveMember
in classMemberDefinition<java.lang.reflect.Method>
- Returns:
null
if can't be resolved
-
invoke
public <R> R invoke(java.lang.Object instance, java.lang.Object... args) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException, java.lang.RuntimeException
Invokes the underlying method represented by thisMethod
object, on the specified object with the specified parameters. Individual parameters are automatically unwrapped to match primitive formal parameters, and both primitive and reference parameters are subject to method invocation conversions as necessary.- Type Parameters:
R
- the type of return value- Parameters:
instance
- the instance for method invocationargs
- the arguments for method invocation- Returns:
- the return value
- Throws:
java.lang.IllegalStateException
- if thisMethod
object is enforcing Java language access control and the underlying method is inaccessible.java.lang.IllegalArgumentException
- if the method is an instance method and the specified object argument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion.java.lang.RuntimeException
- if the underlying method throws an exception.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classReflectiveDefinition
-
-