Class MethodUtils
- java.lang.Object
-
- ch.systemsx.cisd.common.reflection.MethodUtils
-
public final class MethodUtils extends java.lang.Object
Functions aroundMethod
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
describeMethod(java.lang.reflect.Method method)
Describes given method in following format:<class-name>.<method-name>
, for instanceObject.hashCode
.static java.lang.reflect.Method
getCurrentMethod()
Returns the currently calledMethod
.static java.lang.reflect.Method
getMethodOnStack(int level)
Returns theMethod
on the stack of level.static java.lang.String
toString(java.lang.reflect.Method method)
Returns the specified method as string which shows method name and parameter types in a way which more compact thanMethod.toString()
.
-
-
-
Method Detail
-
toString
public static final java.lang.String toString(java.lang.reflect.Method method)
Returns the specified method as string which shows method name and parameter types in a way which more compact thanMethod.toString()
.
-
getCurrentMethod
public static final java.lang.reflect.Method getCurrentMethod()
Returns the currently calledMethod
.Returns
null
if none could be found.
-
getMethodOnStack
public static final java.lang.reflect.Method getMethodOnStack(int level)
Returns theMethod
on the stack of level.level=0
is this method itself,level=1
is the method that called it and so forth. This method internally usesClass.getDeclaredMethods()
to retrieve theMethod
.IMPORTANT NOTE: You should carefully use this method in a class having more than one method with the same name. The internal idea used here (
new Throwable().getStackTrace()
) only returns a method name and does not make any other consideration.- See Also:
StackTraceElement.getMethodName()
-
describeMethod
public static final java.lang.String describeMethod(java.lang.reflect.Method method)
Describes given method in following format:<class-name>.<method-name>
, for instanceObject.hashCode
.
-
-