package uk.co.bristlecone.voltdb.wrapgen.builder.impl;

import java.util.function.Function;

import uk.co.bristlecone.voltdb.wrapgen.builder.ProcData;

/**
 * Provides methods that provide services to a RunnerBuilder, allowing it to create the full class definition.
 * 
 * @author christo
 */
public class RunnerBuilderServices {
  private Function<String, String> packageNamer;
  private Function<String, String> runnerNamer;
  private ProcData procData;

  public RunnerBuilderServices(ProcData procData, Function<String, String> packageNamer,
      Function<String, String> runnerNamer) {
    this.packageNamer = packageNamer;
    this.runnerNamer = runnerNamer;
    this.procData = procData;
  }

  public String procName() {
    return procData.name();
  }

  public String runnerName() {
    return runnerNamer.apply(procName());
  }

  public String procPackageName() {
    return procData.packageName();
  }

  public String runnerPackageName() {
    return packageNamer.apply(procPackageName());
  }

  public String runnerJavaDoc() {
    StringBuilder result = new StringBuilder();
    result.append("An instance of this class can be used to run the <code>");
    result.append(procName());
    result.append("</code> VoltDB stored procedure. This stored procedure's JavaDoc is:\n\n");
    result.append("<blockquote>");
    result.append(procData.classJavaDoc());
    result.append("</blockquote>\n\n");
    result.append("<strong>This class is automatically generated. Manual edits will be overwritten.</strong>\n\n");
    result.append("@author voltdb-wrapgen\n");
    return result.toString();
  }
}

@@ -84,16 +84,136 @@
 unction;
+%0Aimport java.util.stream.Collectors;%0A%0Aimport com.squareup.javapoet.ParameterSpec;%0Aimport com.squareup.javapoet.TypeName;
 %0A%0Aimport
@@ -1725,11 +1725,826 @@
 g();%0A  %7D
+%0A%0A  /**%0A   * @return the parameters to the stored procedure's run method, converting them from RunParameter's to ParameterSpec's%0A   */%0A  public Iterable%3CParameterSpec%3E runMethodParamsAsParameterSpecs() %7B%0A    return procData.parameters()%0A        .stream()%0A        .map(rp -%3E ParameterSpec.builder(TypeName.BYTE, %22foo%22))%0A        // .map(rp -%3E ParameterSpec.builder(ClassName.get(rp.packageName(), rp.typeName()), rp.variableName()))%0A        .map(psb -%3E psb.build())%0A        .collect(Collectors.toList());%0A  %7D%0A%0A  /**%0A   * @return the parameters to the stored procedure's run method as a comma-separated list of variable names%0A   */%0A  public String runMethodParamsAsVariableList() %7B%0A    return procData.parameters()%0A        .stream()%0A        .map(rp -%3E rp.variableName())%0A        .collect(Collectors.joining(%22, %22));%0A  %7D
 %0A%7D%0A

Add utility methods for run method parameters to RunnerBuilderServices