<commit_before>package uk.co.bristlecone.voltdb.wrapgen.builder;

import static com.google.common.base.Preconditions.checkArgument;

import java.util.List;

import com.google.common.collect.ImmutableList;

import uk.co.bristlecone.voltdb.wrapgen.source.ProcReturnType;
import uk.co.bristlecone.voltdb.wrapgen.source.RunParameter;
import uk.co.bristlecone.voltdb.wrapgen.source.SourceFile;

/**
 * An immutable class representing the metadata needed to build a wrapgen runner
 * 
 * @author christo
 */
public class ProcData {
  private final String name;
  private final List<RunParameter> parameters;
  private final ProcReturnType returnType;
  private final String packageName;

  private ProcData(String name, List<RunParameter> parameters, ProcReturnType returnType, String packageName) {
    this.name = name;
    this.parameters = parameters;
    this.returnType = returnType;
    this.packageName = packageName;
  }

  private ProcData(SourceFile source) {
    this.name = source.voltProcedureName();
    this.parameters = source.runMethodParameters();
    this.returnType = source.runMethodReturnType();
    this.packageName = source.packageName();
  }

  /**
   * @return the (unqualified) name of the stored procedure class
   */
  public String name() {
    return name;
  }

  /**
   * @return the parameters to the stored procedure's <code>run</code> method
   */
  public List<RunParameter> parameters() {
    return parameters;
  }

  /**
   * @return the stored procedure's return type
   */
  public ProcReturnType returnType() {
    return returnType;
  }

  /**
   * @return the stored procedure's package
   */
  public String packageName() {
    return packageName;
  }

  /**
   * Allows clear, type-safe building of a ProcData
   * 
   * @author christo
   */
  public static class Builder {
    private String name;
    private List<RunParameter> parameters;
    private ProcReturnType returnType;
    private String packageName;

    public Builder() {
      // intentionally left blank
    }

    public Builder setName(String name) {
      checkArgument(name != null, "name must not be null");
      checkArgument(!name.equals(""), "name must not be empty String");
      this.name = name;
      return this;
    }

    public Builder setParameters(List<RunParameter> parameters) {
      checkArgument(parameters != null, "parameters must not be null");
      this.parameters = ImmutableList.copyOf(parameters);
      return this;
    }

    public Builder setReturnType(ProcReturnType returnType) {
      checkArgument(name != null, "returnType must not be null");
      this.returnType = returnType;
      return this;
    }

    public Builder setPackageName(String packageName) {
      checkArgument(packageName != null, "packageName must not be null");
      this.packageName = packageName;
      return this;
    }

    public ProcData build() {
      return new ProcData(name, parameters, returnType, packageName);
    }
  }
}<commit_msg>clean up ProcData checks for valid builder field values<commit_after>package uk.co.bristlecone.voltdb.wrapgen.builder;

import static com.google.common.base.Preconditions.checkArgument;

import java.util.List;

import com.google.common.collect.ImmutableList;

import uk.co.bristlecone.voltdb.wrapgen.source.ProcReturnType;
import uk.co.bristlecone.voltdb.wrapgen.source.RunParameter;
import uk.co.bristlecone.voltdb.wrapgen.source.SourceFile;

/**
 * An immutable class representing the metadata needed to build a wrapgen runner
 * 
 * @author christo
 */
public class ProcData {
  private final String name;
  private final List<RunParameter> parameters;
  private final ProcReturnType returnType;
  private final String packageName;

  private ProcData(String name, List<RunParameter> parameters, ProcReturnType returnType, String packageName) {
    this.name = name;
    this.parameters = parameters;
    this.returnType = returnType;
    this.packageName = packageName;
  }

  private ProcData(SourceFile source) {
    this.name = source.voltProcedureName();
    this.parameters = source.runMethodParameters();
    this.returnType = source.runMethodReturnType();
    this.packageName = source.packageName();
  }

  /**
   * @return the (unqualified) name of the stored procedure class
   */
  public String name() {
    return name;
  }

  /**
   * @return the parameters to the stored procedure's <code>run</code> method
   */
  public List<RunParameter> parameters() {
    return parameters;
  }

  /**
   * @return the stored procedure's return type
   */
  public ProcReturnType returnType() {
    return returnType;
  }

  /**
   * @return the stored procedure's package
   */
  public String packageName() {
    return packageName;
  }

  /**
   * Allows clear, type-safe building of a ProcData
   * 
   * @author christo
   */
  public static class Builder {
    private String name;
    private List<RunParameter> parameters;
    private ProcReturnType returnType;
    private String packageName;

    public Builder() {
      // intentionally left blank
    }

    public Builder setName(String name) {
      checkName(name);
      this.name = name;
      return this;
    }

    public Builder setParameters(List<RunParameter> parameters) {
      checkParameters(parameters);
      this.parameters = ImmutableList.copyOf(parameters);
      return this;
    }

    public Builder setReturnType(ProcReturnType returnType) {
      checkReturnType(returnType);
      this.returnType = returnType;
      return this;
    }

    public Builder setPackageName(String packageName) {
      checkPackageName(packageName);
      this.packageName = packageName;
      return this;
    }

    private void checkName(String name) {
      checkArgument(name != null, "name must not be null");
      checkArgument(!name.equals(""), "name must not be empty String");
    }

    private void checkParameters(List<RunParameter> parameters) {
      checkArgument(parameters != null, "parameters must not be null");
    }

    private void checkReturnType(ProcReturnType returnType) {
      checkArgument(returnType != null, "returnType must not be null");
    }

    private void checkPackageName(String packageName) {
      checkArgument(packageName != null, "packageName must not be null");
    }

    public ProcData build() {
      checkName(name);
      checkParameters(parameters);
      checkReturnType(returnType);
      checkPackageName(packageName);
      return new ProcData(name, parameters, returnType, packageName);
    }
  }
}
{'fraction_non_alphanumeric': 0.09434542102028273, 'fraction_numerical': 0.0, 'mean_word_length': 3.424881033310673, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2893361', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1781, 'n_words': 494}