// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
package dev.kreuzberg;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import org.jspecify.annotations.Nullable;

/**
 * Configuration for OCR element extraction.
 *
 * Controls how OCR elements are extracted and filtered.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = OcrElementConfig.Builder.class)
public record OcrElementConfig(
    /**
     * Whether to include OCR elements in the extraction result.
     *
     * When true, the {@code ocr_elements} field in {@code ExtractionResult} will be populated.
     */
    @Nullable @JsonProperty("include_elements") Boolean includeElements,
    /**
     * Minimum hierarchical level to include.
     *
     * Elements below this level (e.g., words when min_level is Line) will be excluded.
     */
    @Nullable @JsonProperty("min_level") OcrElementLevel minLevel,
    /**
     * Minimum recognition confidence threshold (0.0-1.0).
     *
     * Elements with confidence below this threshold will be filtered out.
     */
    @Nullable @JsonProperty("min_confidence") Double minConfidence,
    /**
     * Whether to build hierarchical relationships between elements.
     *
     * When true, {@code parent_id} fields will be populated based on spatial containment.
     * Only meaningful for Tesseract output.
     */
    @Nullable @JsonProperty("build_hierarchy") Boolean buildHierarchy
) {
    public static Builder builder() {
        return new Builder();
    }

    // CPD-OFF
    @JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
    public static final class Builder {

        @JsonProperty("include_elements")
private Boolean includeElements = null;
        @JsonProperty("min_level")
        @Nullable private OcrElementLevel minLevel = OcrElementLevel.Line;
        @JsonProperty("min_confidence")
private Double minConfidence = null;
        @JsonProperty("build_hierarchy")
private Boolean buildHierarchy = null;

        /** Sets the includeElements field. */
        @JsonProperty("include_elements")
        public Builder withIncludeElements(final @Nullable Boolean value) {
            this.includeElements = value;
            return this;
        }

        /** Sets the minLevel field. */
        @JsonProperty("min_level")
        public Builder withMinLevel(final @Nullable OcrElementLevel value) {
            this.minLevel = value;
            return this;
        }

        /** Sets the minConfidence field. */
        @JsonProperty("min_confidence")
        public Builder withMinConfidence(final @Nullable Double value) {
            this.minConfidence = value;
            return this;
        }

        /** Sets the buildHierarchy field. */
        @JsonProperty("build_hierarchy")
        public Builder withBuildHierarchy(final @Nullable Boolean value) {
            this.buildHierarchy = value;
            return this;
        }

        /** Builds the OcrElementConfig instance. */
        public OcrElementConfig build() {
            return new OcrElementConfig(
                includeElements,
                minLevel,
                minConfidence,
                buildHierarchy
            );
        }
    }
    // CPD-ON
}
