Annotation Interface OverwriteMethod


@Target(METHOD) @Retention(RUNTIME) public @interface OverwriteMethod

Annotates a static method to indicate it will be intercepting a method in a target. the value() of this annotation must be the name of the method you want to intercept. You will be passed an instance of a Method object which you can optionally .invoke() if you want to have the intercepted function's method execute, otherwise, it won't.
If you have no need to call the original method, you can omit the Method argument from yours. Whatever you call your own method is irrelevant.

Here are some examples - assume they all are for methods in a class called TargetClass

theirs: int someMethod(String, int)
yours: public static int myInterceptor(TargetClass, Method, String, int)

theirs: static String someStaticMethod(boolean, Integer)
yours: public static String myInterceptor(Method, boolean, Integer)

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Element Details

    • value

      String value
      Returns:
      The name of the method to intercept. E.g. "SomeMethod"