private JCTree makeCallMethod(List<JCStatement> body, int numParams) {
    MethodDefinitionBuilder callMethod = MethodDefinitionBuilder.callable(gen);
    callMethod.isOverride(true);
    callMethod.modifiers(Flags.PUBLIC);
    ProducedType returnType = gen.getReturnTypeOfCallable(typeModel);
    callMethod.resultType(gen.makeJavaType(returnType, JT_NO_PRIMITIVES), null);
    // Now append formal parameters
    switch (numParams) {
      case 3:
        callMethod.parameter(makeCallableCallParam(0, numParams - 3));
        // fall through
      case 2:
        callMethod.parameter(makeCallableCallParam(0, numParams - 2));
        // fall through
      case 1:
        callMethod.parameter(makeCallableCallParam(0, numParams - 1));
        break;
      case 0:
        break;
      default: // use varargs
        callMethod.parameter(makeCallableCallParam(Flags.VARARGS, 0));
    }

    // Return the call result, or null if a void method
    callMethod.body(body);
    return callMethod.build();
  }
  /**
   * Appends to <tt>defs</tt> the definitions that would go into the class generated by {@link
   * #build()}
   *
   * @param defs a {@link ListBuffer} to which the definitions will be appended.
   */
  public void appendDefinitionsTo(ListBuffer<JCTree> defs) {
    if (hasField) {
      defs.append(generateField());
      if (variableInit != null) defs.append(generateFieldInit());
    }

    if (readable) {
      getterBuilder.modifiers(getGetSetModifiers());
      getterBuilder.noAnnotations(noAnnotations);
      defs.append(getterBuilder.build());
    }

    if (writable) {
      setterBuilder.modifiers(getGetSetModifiers());
      setterBuilder.noAnnotations(noAnnotations);
      defs.append(setterBuilder.build());
    }
  }
 private JCTree makeCallTypedMethod(
     List<JCStatement> body, java.util.List<ProducedType> parameterTypes) {
   // make the method
   MethodDefinitionBuilder methodBuilder =
       MethodDefinitionBuilder.method(gen, false, Naming.getCallableTypedMethodName());
   methodBuilder.modifiers(Flags.PRIVATE);
   ProducedType returnType = gen.getReturnTypeOfCallable(typeModel);
   methodBuilder.resultType(gen.makeJavaType(returnType, JT_NO_PRIMITIVES), null);
   // add all parameters
   int i = 0;
   for (Parameter param : paramLists.getParameters()) {
     ParameterDefinitionBuilder parameterBuilder =
         ParameterDefinitionBuilder.instance(gen, param.getName());
     JCExpression paramType = gen.makeJavaType(parameterTypes.get(i));
     parameterBuilder.type(paramType, null);
     methodBuilder.parameter(parameterBuilder);
     i++;
   }
   // Return the call result, or null if a void method
   methodBuilder.body(body);
   return methodBuilder.build();
 }