<commit_before>package com.saasquatch.jsonschemainferrer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * Builder for {@link JsonSchemaInferrer}. This class is mutable and not thread safe.
 *
 * @author sli
 * @see JsonSchemaInferrer#newBuilder()
 */
@NotThreadSafe
public final class JsonSchemaInferrerBuilder {

  private SpecVersion specVersion = SpecVersion.DRAFT_04;
  private IntegerTypePreference integerTypePreference = IntegerTypePreference.IF_ALL;
  private IntegerTypeCriterion integerTypeCriterion = IntegerTypeCriteria.nonFloatingPoint();
  private AdditionalPropertiesPolicy additionalPropertiesPolicy =
      AdditionalPropertiesPolicies.noOp();
  private RequiredPolicy requiredPolicy = RequiredPolicies.noOp();
  private DefaultPolicy defaultPolicy = DefaultPolicies.noOp();
  private ExamplesPolicy examplesPolicy = ExamplesPolicies.noOp();
  private FormatInferrer formatInferrer = FormatInferrers.noOp();
  private TitleDescriptionGenerator titleDescriptionGenerator = TitleDescriptionGenerators.noOp();
  private MultipleOfPolicy multipleOfPolicy = MultipleOfPolicies.noOp();
  private Set<ObjectSizeFeature> objectSizeFeatures = Collections.emptySet();
  private Set<ArrayLengthFeature> arrayLengthFeatures = Collections.emptySet();
  private Set<StringLengthFeature> stringLengthFeatures = Collections.emptySet();
  private Set<NumberRangeFeature> numberRangeFeatures = Collections.emptySet();
  private final Collection<GenericSchemaFeature> additionalSchemaFeatures = new ArrayList<>();

  JsonSchemaInferrerBuilder() {}

  /**
   * Set the specification version. The default is draft-04.
   */
  public JsonSchemaInferrerBuilder setSpecVersion(@Nonnull SpecVersion specVersion) {
    this.specVersion = Objects.requireNonNull(specVersion);
    return this;
  }

  /**
   * Set the {@link IntegerTypePreference}. The default is {@link IntegerTypePreference#IF_ALL}.
   */
  public JsonSchemaInferrerBuilder setIntegerTypePreference(
      @Nonnull IntegerTypePreference integerTypePreference) {
    this.integerTypePreference = Objects.requireNonNull(integerTypePreference);
    return this;
  }

  /**
   * Set the {@link IntegerTypeCriterionL}. The default is
   * {@link IntegerTypeCriteria#nonFloatingPoint()}.
   */
  public JsonSchemaInferrerBuilder setIntegerTypeCriterion(
      @Nonnull IntegerTypeCriterion integerTypeCriterion) {
    this.integerTypeCriterion = Objects.requireNonNull(integerTypeCriterion);
    return this;
  }

  /**
   * Set the {@link AdditionalPropertiesPolicy}. By default it is
   * {@link AdditionalPropertiesPolicies#noOp()}.
   *
   * @see AdditionalPropertiesPolicy
   * @see AdditionalPropertiesPolicies
   */
  public JsonSchemaInferrerBuilder setAdditionalPropertiesPolicy(
      @Nonnull AdditionalPropertiesPolicy additionalPropertiesPolicy) {
    this.additionalPropertiesPolicy = Objects.requireNonNull(additionalPropertiesPolicy);
    return this;
  }

  /**
   * Set the {@link RequiredPolicy}. By default it is {@link RequiredPolicies#noOp()}.
   *
   * @see RequiredPolicy
   * @see RequiredPolicies
   */
  public JsonSchemaInferrerBuilder setRequiredPolicy(@Nonnull RequiredPolicy requiredPolicy) {
    this.requiredPolicy = Objects.requireNonNull(requiredPolicy);
    return this;
  }

  /**
   * Set the {@link DefaultPolicy}. By default it is {@link DefaultPolicies#noOp()}.
   *
   * @see DefaultPolicy
   * @see DefaultPolicies
   */
  public JsonSchemaInferrerBuilder setDefaultPolicy(@Nonnull DefaultPolicy defaultPolicy) {
    this.defaultPolicy = Objects.requireNonNull(defaultPolicy);
    return this;
  }

  /**
   * Set the {@link ExamplesPolicy}. By default is {@link ExamplesPolicies#noOp()}.
   *
   * @see ExamplesPolicy
   * @see ExamplesPolicies
   */
  public JsonSchemaInferrerBuilder setExamplesPolicy(@Nonnull ExamplesPolicy examplesPolicy) {
    this.examplesPolicy = Objects.requireNonNull(examplesPolicy);
    return this;
  }

  /**
   * Set the {@link FormatInferrer} for inferring the <a href=
   * "https://json-schema.org/understanding-json-schema/reference/string.html#format">format</a> of
   * strings. By default it uses {@link FormatInferrers#noOp()}. An example of a possible custom
   * implementation is available at {@link FormatInferrers#dateTime()}, which you can potentially
   * use or use it combined with your own implementations with
   * {@link FormatInferrers#chained(FormatInferrer...)}.<br>
   * Note that if your JSON samples have large nested arrays, it's recommended to set this to false
   * to prevent confusing outputs.
   *
   * @see FormatInferrer
   * @see FormatInferrers
   */
  public JsonSchemaInferrerBuilder setFormatInferrer(@Nonnull FormatInferrer formatInferrer) {
    this.formatInferrer = Objects.requireNonNull(formatInferrer);
    return this;
  }

  /**
   * Set the {@link TitleDescriptionGenerator} for this inferrer. By default it is
   * {@link TitleDescriptionGenerators#noOp()}. You can provide your custom implementations and
   * transform the field names however you see fit.
   *
   * @see TitleDescriptionGenerator
   * @see TitleDescriptionGenerators
   */
  public JsonSchemaInferrerBuilder setTitleDescriptionGenerator(
      @Nonnull TitleDescriptionGenerator titleDescriptionGenerator) {
    this.titleDescriptionGenerator = Objects.requireNonNull(titleDescriptionGenerator);
    return this;
  }

  /**<commit_msg>rearrange methods<commit_after>package com.saasquatch.jsonschemainferrer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * Builder for {@link JsonSchemaInferrer}. This class is mutable and not thread safe.
 *
 * @author sli
 * @see JsonSchemaInferrer#newBuilder()
 */
@NotThreadSafe
public final class JsonSchemaInferrerBuilder {

  private SpecVersion specVersion = SpecVersion.DRAFT_04;
  private IntegerTypePreference integerTypePreference = IntegerTypePreference.IF_ALL;
  private IntegerTypeCriterion integerTypeCriterion = IntegerTypeCriteria.nonFloatingPoint();
  private FormatInferrer formatInferrer = FormatInferrers.noOp();
  private TitleDescriptionGenerator titleDescriptionGenerator = TitleDescriptionGenerators.noOp();
  private AdditionalPropertiesPolicy additionalPropertiesPolicy =
      AdditionalPropertiesPolicies.noOp();
  private RequiredPolicy requiredPolicy = RequiredPolicies.noOp();
  private DefaultPolicy defaultPolicy = DefaultPolicies.noOp();
  private ExamplesPolicy examplesPolicy = ExamplesPolicies.noOp();
  private MultipleOfPolicy multipleOfPolicy = MultipleOfPolicies.noOp();
  private Set<ObjectSizeFeature> objectSizeFeatures = Collections.emptySet();
  private Set<ArrayLengthFeature> arrayLengthFeatures = Collections.emptySet();
  private Set<StringLengthFeature> stringLengthFeatures = Collections.emptySet();
  private Set<NumberRangeFeature> numberRangeFeatures = Collections.emptySet();
  private final Collection<GenericSchemaFeature> additionalSchemaFeatures = new ArrayList<>();

  JsonSchemaInferrerBuilder() {}

  /**
   * Set the specification version. The default is draft-04.
   */
  public JsonSchemaInferrerBuilder setSpecVersion(@Nonnull SpecVersion specVersion) {
    this.specVersion = Objects.requireNonNull(specVersion);
    return this;
  }

  /**
   * Set the {@link IntegerTypePreference}. The default is {@link IntegerTypePreference#IF_ALL}.
   */
  public JsonSchemaInferrerBuilder setIntegerTypePreference(
      @Nonnull IntegerTypePreference integerTypePreference) {
    this.integerTypePreference = Objects.requireNonNull(integerTypePreference);
    return this;
  }

  /**
   * Set the {@link IntegerTypeCriterionL}. The default is
   * {@link IntegerTypeCriteria#nonFloatingPoint()}.
   */
  public JsonSchemaInferrerBuilder setIntegerTypeCriterion(
      @Nonnull IntegerTypeCriterion integerTypeCriterion) {
    this.integerTypeCriterion = Objects.requireNonNull(integerTypeCriterion);
    return this;
  }

  /**
   * Set the {@link FormatInferrer} for inferring the <a href=
   * "https://json-schema.org/understanding-json-schema/reference/string.html#format">format</a> of
   * strings. By default it uses {@link FormatInferrers#noOp()}. An example of a possible custom
   * implementation is available at {@link FormatInferrers#dateTime()}, which you can potentially
   * use or use it combined with your own implementations with
   * {@link FormatInferrers#chained(FormatInferrer...)}.<br>
   * Note that if your JSON samples have large nested arrays, it's recommended to set this to false
   * to prevent confusing outputs.
   *
   * @see FormatInferrer
   * @see FormatInferrers
   */
  public JsonSchemaInferrerBuilder setFormatInferrer(@Nonnull FormatInferrer formatInferrer) {
    this.formatInferrer = Objects.requireNonNull(formatInferrer);
    return this;
  }

  /**
   * Set the {@link TitleDescriptionGenerator} for this inferrer. By default it is
   * {@link TitleDescriptionGenerators#noOp()}. You can provide your custom implementations and
   * transform the field names however you see fit.
   *
   * @see TitleDescriptionGenerator
   * @see TitleDescriptionGenerators
   */
  public JsonSchemaInferrerBuilder setTitleDescriptionGenerator(
      @Nonnull TitleDescriptionGenerator titleDescriptionGenerator) {
    this.titleDescriptionGenerator = Objects.requireNonNull(titleDescriptionGenerator);
    return this;
  }

  /**
   * Set the {@link AdditionalPropertiesPolicy}. By default it is
   * {@link AdditionalPropertiesPolicies#noOp()}.
   *
   * @see AdditionalPropertiesPolicy
   * @see AdditionalPropertiesPolicies
   */
  public JsonSchemaInferrerBuilder setAdditionalPropertiesPolicy(
      @Nonnull AdditionalPropertiesPolicy additionalPropertiesPolicy) {
    this.additionalPropertiesPolicy = Objects.requireNonNull(additionalPropertiesPolicy);
    return this;
  }

  /**
   * Set the {@link RequiredPolicy}. By default it is {@link RequiredPolicies#noOp()}.
   *
   * @see RequiredPolicy
   * @see RequiredPolicies
   */
  public JsonSchemaInferrerBuilder setRequiredPolicy(@Nonnull RequiredPolicy requiredPolicy) {
    this.requiredPolicy = Objects.requireNonNull(requiredPolicy);
    return this;
  }

  /**
   * Set the {@link DefaultPolicy}. By default it is {@link DefaultPolicies#noOp()}.
   *
   * @see DefaultPolicy
   * @see DefaultPolicies
   */
  public JsonSchemaInferrerBuilder setDefaultPolicy(@Nonnull DefaultPolicy defaultPolicy) {
    this.defaultPolicy = Objects.requireNonNull(defaultPolicy);
    return this;
  }

  /**
   * Set the {@link ExamplesPolicy}. By default is {@link ExamplesPolicies#noOp()}.
   *
   * @see ExamplesPolicy
   * @see ExamplesPolicies
   */
  public JsonSchemaInferrerBuilder setExamplesPolicy(@Nonnull ExamplesPolicy examplesPolicy) {
    this.examplesPolicy = Objects.requireNonNull(examplesPolicy);
    return this;
  }

  /**
{'fraction_non_alphanumeric': 0.08536802708964535, 'fraction_numerical': 0.0007128854036713598, 'mean_word_length': 4.957006369426751, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '5714133', 'n_tokens_mistral': 2982, 'n_tokens_neox': 2959, 'n_words': 747}