Annotation Interface Intercept
Declares a class as a handler for calls the scanned code makes to an API.
The handler mirrors the API it intercepts. Whenever the scanner finds a call to the target class, it reconstructs the arguments and invokes the handler's static method with the same name and number of parameters. For an instance method, the receiver is passed as the first argument.
@Intercept("com.example.api.ColorRegistry")
public class ColorRegistry {
@Intercept.Capture
public static CaptureChannel<Color> CAPTURE;
public static void register(String name, Color color) {
CAPTURE.emit(color);
}
}
Each argument is converted to the handler's parameter type:
- A
Conduitinterface wraps the reconstructed value. - A
Supplier<T>evaluates the lambda or method reference that was passed, and only whenget()is called.Tmay be a conduit, orTracefor the raw result. - Strings, numbers and booleans are passed through when they are compile-time
constants, and are
nullotherwise. Valuereceives the reconstructed value as is.
A matched call is not stepped into. If a handler intercepts both a wrapper API and the API it wraps, a registration through the wrapper is reported once, not twice.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceMarks a staticCaptureChannelfield on a handler to be created when the handler is registered. -
Required Element Summary
Required Elements
-
Element Details
-
value
String valueThe binary name of the class whose calls are intercepted.- Returns:
- the target class name
-