// 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.databind.JsonNode;
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;

/**
 * The complete diff between two {@code ExtractionResult} values.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ExtractionDiff.Builder.class)
public record ExtractionDiff(
    /**
     * Unified-diff hunks for the {@code content} field.
     *
     * Empty when the content is identical.
     */
    @JsonProperty("content_diff") List<DiffHunk> contentDiff,
    /**
     * Tables present in {@code b} but not in {@code a} (by index position, excess right-side tables).
     */
    @JsonProperty("tables_added") List<Table> tablesAdded,
    /**
     * Tables present in {@code a} but not in {@code b} (by index position, excess left-side tables).
     */
    @JsonProperty("tables_removed") List<Table> tablesRemoved,
    /**
     * Cell-level changes for table pairs that share the same index and dimensions.
     */
    @JsonProperty("tables_changed") List<TableDiff> tablesChanged,
    /**
     * Metadata difference, encoded as a JSON object with three top-level keys:
     * {@code added} (keys present in {@code b} but not {@code a}), {@code removed} (keys present in {@code a}
     * but not {@code b}), and {@code changed} (keys whose values differ — each entry is
     * {@code { "from": &lt;value-in-a&gt;, "to": &lt;value-in-b&gt; }}).
     *
     * This is NOT RFC 6902 JSON Patch — we deliberately chose a flatter shape
     * to avoid pulling in a json-patch crate. If you need RFC 6902 semantics
     * (with JSON Pointer paths) feed {@code a.metadata} and {@code b.metadata} to your
     * preferred json-patch impl directly.
     */
    @JsonProperty("metadata_changed") JsonNode metadataChanged,
    /**
     * Changes to embedded archive children.
     */
    @JsonProperty("embedded_changes") EmbeddedChanges embeddedChanges
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("content_diff")
private List<DiffHunk> contentDiff = List.of();
        @JsonProperty("tables_added")
private List<Table> tablesAdded = List.of();
        @JsonProperty("tables_removed")
private List<Table> tablesRemoved = List.of();
        @JsonProperty("tables_changed")
private List<TableDiff> tablesChanged = List.of();
        @JsonProperty("metadata_changed")
private JsonNode metadataChanged = null;
        @JsonProperty("embedded_changes")
private EmbeddedChanges embeddedChanges = null;

        /** Sets the contentDiff field. */
        @JsonProperty("content_diff")
        public Builder withContentDiff(final List<DiffHunk> value) {
            this.contentDiff = value;
            return this;
        }

        /** Sets the tablesAdded field. */
        @JsonProperty("tables_added")
        public Builder withTablesAdded(final List<Table> value) {
            this.tablesAdded = value;
            return this;
        }

        /** Sets the tablesRemoved field. */
        @JsonProperty("tables_removed")
        public Builder withTablesRemoved(final List<Table> value) {
            this.tablesRemoved = value;
            return this;
        }

        /** Sets the tablesChanged field. */
        @JsonProperty("tables_changed")
        public Builder withTablesChanged(final List<TableDiff> value) {
            this.tablesChanged = value;
            return this;
        }

        /** Sets the metadataChanged field. */
        @JsonProperty("metadata_changed")
        public Builder withMetadataChanged(final JsonNode value) {
            this.metadataChanged = value;
            return this;
        }

        /** Sets the embeddedChanges field. */
        @JsonProperty("embedded_changes")
        public Builder withEmbeddedChanges(final EmbeddedChanges value) {
            this.embeddedChanges = value;
            return this;
        }

        /** Builds the ExtractionDiff instance. */
        public ExtractionDiff build() {
            return new ExtractionDiff(
                contentDiff,
                tablesAdded,
                tablesRemoved,
                tablesChanged,
                metadataChanged,
                embeddedChanges
            );
        }
    }
    // CPD-ON
}
