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

/**
 * Cell-level changes for a pair of tables that share the same index.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = TableDiff.Builder.class)
public record TableDiff(
    /**
     * Zero-based index of the table in both {@code a.tables} and {@code b.tables}.
     */
    @JsonProperty("from_index") long fromIndex,
    /**
     * Zero-based index in {@code b.tables} (equal to {@code from_index} for same-dimension tables).
     */
    @JsonProperty("to_index") long toIndex,
    /**
     * Cell-level changes within the table.
     */
    @JsonProperty("cell_changes") List<CellChange> cellChanges
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("from_index")
private long fromIndex = 0;
        @JsonProperty("to_index")
private long toIndex = 0;
        @JsonProperty("cell_changes")
private List<CellChange> cellChanges = List.of();

        /** Sets the fromIndex field. */
        @JsonProperty("from_index")
        public Builder withFromIndex(final long value) {
            this.fromIndex = value;
            return this;
        }

        /** Sets the toIndex field. */
        @JsonProperty("to_index")
        public Builder withToIndex(final long value) {
            this.toIndex = value;
            return this;
        }

        /** Sets the cellChanges field. */
        @JsonProperty("cell_changes")
        public Builder withCellChanges(final List<CellChange> value) {
            this.cellChanges = value;
            return this;
        }

        /** Builds the TableDiff instance. */
        public TableDiff build() {
            return new TableDiff(
                fromIndex,
                toIndex,
                cellChanges
            );
        }
    }
    // CPD-ON
}
