// 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;

/**
 * Pre-computed table markdown for a table detection region.
 *
 * Produced by the TATR-based table structure recognizer and surfaced as part of
 * layout-aware OCR results.  The struct lives here (under {@code layout-types}, pure-Rust)
 * so that consumers who do not enable {@code layout-detection} (ORT) can still reference
 * the type in their own code.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = RecognizedTable.Builder.class)
public record RecognizedTable(
    /**
     * Detection bbox that this table corresponds to (for matching).
     */
    @JsonProperty("detection_bbox") BBox detectionBbox,
    /**
     * Table cells as a 2D vector (rows × columns).
     */
    @JsonProperty("cells") List<List<String>> cells,
    /**
     * Rendered markdown table.
     */
    @JsonProperty("markdown") String markdown
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("detection_bbox")
private BBox detectionBbox = null;
private List<List<String>> cells = List.of();
private String markdown = "";

        /** Sets the detectionBbox field. */
        @JsonProperty("detection_bbox")
        public Builder withDetectionBbox(final BBox value) {
            this.detectionBbox = value;
            return this;
        }

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

        /** Sets the markdown field. */
        @JsonProperty("markdown")
        public Builder withMarkdown(final String value) {
            this.markdown = value;
            return this;
        }

        /** Builds the RecognizedTable instance. */
        public RecognizedTable build() {
            return new RecognizedTable(
                detectionBbox,
                cells,
                markdown
            );
        }
    }
    // CPD-ON
}
