// 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 java.util.List;
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;

/**
 * Multi-backend OCR pipeline with quality-based fallback.
 *
 * Backends are tried in priority order (highest first). After each backend
 * produces output, quality is evaluated. If it meets {@code quality_thresholds.pipeline_min_quality},
 * the result is accepted. Otherwise the next backend is tried.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = OcrPipelineConfig.Builder.class)
public record OcrPipelineConfig(
    /**
     * Ordered list of backends to try. Sorted by priority (descending) at runtime.
     */
    @JsonProperty("stages") List<OcrPipelineStage> stages,
    /**
     * Quality thresholds for deciding whether to accept a result or try the next backend.
     */
    @Nullable @JsonProperty("quality_thresholds") OcrQualityThresholds qualityThresholds
) {
    public static Builder builder() {
        return new Builder();
    }

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

private List<OcrPipelineStage> stages = List.of();
        @JsonProperty("quality_thresholds")
        @Nullable private OcrQualityThresholds qualityThresholds = null;

        /** Sets the stages field. */
        @JsonProperty("stages")
        public Builder withStages(final List<OcrPipelineStage> value) {
            this.stages = value;
            return this;
        }

        /** Sets the qualityThresholds field. */
        @JsonProperty("quality_thresholds")
        public Builder withQualityThresholds(final @Nullable OcrQualityThresholds value) {
            this.qualityThresholds = value;
            return this;
        }

        /** Builds the OcrPipelineConfig instance. */
        public OcrPipelineConfig build() {
            return new OcrPipelineConfig(
                stages,
                qualityThresholds
            );
        }
    }
    // CPD-ON
}
