-
-
Notifications
You must be signed in to change notification settings - Fork 5
COverride
The COverride
annotation can be used to completely override a method.
When overriding a method, the name of the transformer method is matched against the target method.
The target method name can also be specified using the value
field of the COverride
annotation.
The method signature of the transformer method depends on the target method.
When injecting into a static method, the transformer method also needs to be static and vice versa.
All parameters and the return type of the transformer method have to match the target method.
The access modifier of the transformer method has to be the same as the target method or less restrictive.
private < package < protected < public
Current Access Modifier | Possible Access Modifiers |
---|---|
private | private, package, protected, public |
package | package, protected, public |
protected | protected, public |
public | public |
The value
field can be an array of strings to target multiple methods.
The transformer method needs to be compatible with all targeted methods.
@COverride(value = {"method1", "method2"}, ...)
public void transform()
Original method:
private String method(final String arg) {
return "hello " + arg;
}
Transformer method:
@COverride
public String method(final String arg) {
return "world";
}