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

/**
 * A single contiguous hunk in a unified diff.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = DiffHunk.Builder.class)
public record DiffHunk(
    /**
     * Starting line number in the old content (0-indexed).
     */
    @JsonProperty("from_line") long fromLine,
    /**
     * Number of lines from the old content in this hunk.
     */
    @JsonProperty("from_count") long fromCount,
    /**
     * Starting line number in the new content (0-indexed).
     */
    @JsonProperty("to_line") long toLine,
    /**
     * Number of lines from the new content in this hunk.
     */
    @JsonProperty("to_count") long toCount,
    /**
     * Lines that make up this hunk.
     */
    @JsonProperty("lines") List<DiffLine> lines
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("from_line")
private long fromLine = 0;
        @JsonProperty("from_count")
private long fromCount = 0;
        @JsonProperty("to_line")
private long toLine = 0;
        @JsonProperty("to_count")
private long toCount = 0;
private List<DiffLine> lines = List.of();

        /** Sets the fromLine field. */
        @JsonProperty("from_line")
        public Builder withFromLine(final long value) {
            this.fromLine = value;
            return this;
        }

        /** Sets the fromCount field. */
        @JsonProperty("from_count")
        public Builder withFromCount(final long value) {
            this.fromCount = value;
            return this;
        }

        /** Sets the toLine field. */
        @JsonProperty("to_line")
        public Builder withToLine(final long value) {
            this.toLine = value;
            return this;
        }

        /** Sets the toCount field. */
        @JsonProperty("to_count")
        public Builder withToCount(final long value) {
            this.toCount = value;
            return this;
        }

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

        /** Builds the DiffHunk instance. */
        public DiffHunk build() {
            return new DiffHunk(
                fromLine,
                fromCount,
                toLine,
                toCount,
                lines
            );
        }
    }
    // CPD-ON
}
