public interface GeneratingMethodReaderInterceptorReturns
extends net.openhft.chronicle.bytes.MethodReaderInterceptorReturns
This interface is a version of method reader interceptor that allows to change the logic of
MethodReader without overhead provided by reflexive calls.
Code returned by codeBeforeCall(Method, String, String[]) and
codeAfterCall(Method, String, String[]) will be added before and after actual method call in the generated
source code of the method reader. It's possible to use original call arguments and object instance in the added code.
Simple example that allows to skip call of method "foo" in case its second argument is null:
public String codeBeforeCall(Method m, String objectName, String[] argumentNames) {
if (m.getName().equals("foo"))
return "if (" + argumentNames[1] + " != null) {";
else
return "";
}
public String codeAfterCall(Method m, String objectName, String[] argumentNames) {
if (m.getName().equals("foo"))
return "}";
else
return "";
}
Please mind that if provided code fails to compile, reflexive method call will be delegated to the interceptor
with MethodReaderInterceptorReturns.intercept(Method, Object, Object[], Invocation), like it happens with a regular
MethodReaderInterceptorReturns.
| Modifier and Type | Method and Description |
|---|---|
String |
codeAfterCall(Method m,
String objectName,
String[] argumentNames) |
String |
codeBeforeCall(Method m,
String objectName,
String[] argumentNames) |
String |
generatorId()
Specifies ID of this generating interceptor.
Contract: if the code provided by generating interceptor differs from the code provided by another generating interceptor, theirs IDs should be different as well. |
String generatorId()
String codeBeforeCall(Method m, String objectName, String[] argumentNames)
m - Calling method.objectName - Object instance name.argumentNames - Call argument names.Copyright © 2023. All rights reserved.