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

/**
 * Plain text and Markdown extraction result.
 *
 * Contains the extracted text along with statistics and,
 * for Markdown files, structural elements like headers and links.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = TextExtractionResult.Builder.class)
public record TextExtractionResult(
    /**
     * Extracted text content
     */
    @JsonProperty("content") String content,
    /**
     * Number of lines
     */
    @JsonProperty("line_count") long lineCount,
    /**
     * Number of words
     */
    @JsonProperty("word_count") long wordCount,
    /**
     * Number of characters
     */
    @JsonProperty("character_count") long characterCount,
    /**
     * Markdown headers (text only, Markdown files only)
     */
    @Nullable @JsonProperty("headers") List<String> headers,
    /**
     * Markdown links as (text, URL) tuples (Markdown files only)
     */
    @Nullable @JsonProperty("links") List<List<String>> links,
    /**
     * Code blocks as (language, code) tuples (Markdown files only)
     */
    @Nullable @JsonProperty("code_blocks") List<List<String>> codeBlocks
) {
    public static Builder builder() {
        return new Builder();
    }

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

private String content = "";
        @JsonProperty("line_count")
private long lineCount = 0;
        @JsonProperty("word_count")
private long wordCount = 0;
        @JsonProperty("character_count")
private long characterCount = 0;
private List<String> headers = null;
private List<List<String>> links = null;
        @JsonProperty("code_blocks")
private List<List<String>> codeBlocks = null;

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

        /** Sets the lineCount field. */
        @JsonProperty("line_count")
        public Builder withLineCount(final long value) {
            this.lineCount = value;
            return this;
        }

        /** Sets the wordCount field. */
        @JsonProperty("word_count")
        public Builder withWordCount(final long value) {
            this.wordCount = value;
            return this;
        }

        /** Sets the characterCount field. */
        @JsonProperty("character_count")
        public Builder withCharacterCount(final long value) {
            this.characterCount = value;
            return this;
        }

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

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

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

        /** Builds the TextExtractionResult instance. */
        public TextExtractionResult build() {
            return new TextExtractionResult(
                content,
                lineCount,
                wordCount,
                characterCount,
                headers,
                links,
                codeBlocks
            );
        }
    }
    // CPD-ON
}
