public class MethodDescriptor extends Object
Constructor and Description |
---|
MethodDescriptor(Method method)
Create a
MethodDescriptor based on a method object.
|
MethodDescriptor(String methodDescriptor)
Creates a
MethodDescriptor based on its String representation.
|
MethodDescriptor(String name, String[] parameterTypeNames)
Creates a method descriptor based on the name of the method and the name of the type of the parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getMethodName()
Returns the name of the method.
|
String[] |
getParameterTypeNames()
Returns a clone of the parameter type array.
|
int |
hashCode() |
Method |
locate(Class> clazz, boolean privateMethodAccepted)
Searching the method in the provided class and in super classes.
|
boolean |
matches(Method method)
Matches the provided method with this
MethodDescriptor .
|
String |
toString()
Returns the String representation of this
MethodDescriptor .
|
public MethodDescriptor(Method method)
MethodDescriptor
based on a method object. The parameters types will be listed with their canonical name.
method
- The method that is converted to a MethodDescriptor
.public MethodDescriptor(String methodDescriptor)
MethodDescriptor
based on its String
representation.
methodDescriptor
- The string representation of the MethodDescriptor
. See toString()
.NullPointerException
- if the methodDescriptor parameter is null
.IllegalArgumentException
- if the provided String
representation cannot be parsed.public MethodDescriptor(String name, String[] parameterTypeNames)
name
- The name of the method.parameterTypeNames
- The name of parameter types or null
if the parameters are not defined. In case the parameters are not defined, the locate(Class, boolean)
method will return with the first found method that has the specified name. The type names can be specified in the form of Class.getCanonicalName()
or Class.getSimpleName()
.NullPointerException
- if the name parameter is null
or any of the element of parameterTypeNames is null
.public String getMethodName()
public String[] getParameterTypeNames()
MethodDescriptor
instance.
public Method locate(Class> clazz, boolean privateMethodAccepted)
matches(Method)
and MethodUtil.locateMethodByPreference(Class, boolean, MethodDescriptor...)
.
clazz
- The class where the search starts.privateMethodAccepted
- Whether to search private methods in the class that is passed in the clazz parameter.NullPointerException
- if the clazz parameter is null.public boolean matches(Method method)
MethodDescriptor
. A method matches to this descriptor if the method name is the same and if the parameters of the method match the getParameterTypeNames()
array. If getParameterTypeNames()
returns null, the method will return true if the passed method has the same name as the one that is specified in this MethodDescriptor
.
method
- The method object.MethodDescriptor
.public String toString()
MethodDescriptor
. The string representation contains the name of the method and if available, the list of parameter types enclosed with brackets. The String
that is generated by this method can be passed to the MethodDescriptor(String)
constructor. Parameter type names are listed as they are stored in the MethodDescriptor
, the type name might be a Class.getCanonicalName()
or a Class.getSimpleName()
. Examples: "myMethod", myMethod(java.lang.String), myMethod(String).
Copyright © 2015 Everit Kft.. All rights reserved.