use of com.helger.jcodemodel.JInvocation in project androidannotations by androidannotations.
the class TraceHandler method getEnterMessage.
private IJExpression getEnterMessage(JMethod method, ExecutableElement element) {
String methodName = getMethodName(element);
List<JVar> params = method.params();
if (params.isEmpty()) {
// early exit if the method has no parameters
return JExpr.lit("Entering [" + methodName + "()]");
}
AbstractJClass arraysClass = getJClass(Arrays.class);
StringBuilder paramStr = new StringBuilder();
List<IJExpression> paramExpressions = new ArrayList<>();
for (int i = 0; i < params.size(); i++) {
if (i > 0) {
paramStr.append(", ");
}
JVar var = params.get(i);
paramStr.append(var.name()).append(" = %s");
if (var.type().isArray()) {
paramExpressions.add(arraysClass.staticInvoke("toString").arg(var));
} else {
paramExpressions.add(var);
}
}
JInvocation format = getJClass(String.class).staticInvoke("format");
format.arg(JExpr.lit("Entering [" + methodName + "(" + paramStr + ")]"));
for (IJExpression expr : paramExpressions) {
format.arg(expr);
}
return format;
}
Aggregations