What you will need to do is store an intermediate value for each invoke() JExpression call:
JExpression rhsAssignmentExpression = JExpr._new(refArrayList);
for(String methodName : methodsToInvoke) {
rhsAssignmentExpression = rhsAssignmentExpression.invoke(methodName).arg(JExpr._new(refObject));
}
This avoids redefining the invocation each time, and effectively chains the calls. The result is the following:
public class GeneratedClass {
public ArrayList objects;
public ArrayList getNewObjectList() {
objects = new ArrayList().add(new Object()).add(new Object()).add(new Object());
return objects;
}
}