Class MethodUtils

java.lang.Object
ch.systemsx.cisd.common.reflection.MethodUtils

public final class MethodUtils extends Object
Functions around Method.
  • Method Details

    • toString

      public static final String toString(Method method)
      Returns the specified method as string which shows method name and parameter types in a way which more compact than Method.toString().
    • getCurrentMethod

      public static final Method getCurrentMethod()
      Returns the currently called Method.

      Returns null if none could be found.

    • getMethodOnStack

      public static final Method getMethodOnStack(int level)
      Returns the Method 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 uses Class.getDeclaredMethods() to retrieve the Method.

      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:
    • describeMethod

      public static final String describeMethod(Method method)
      Describes given method in following format: <class-name>.<method-name>, for instance Object.hashCode.