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

/**
 * Byte offset boundary for a page.
 *
 * Tracks where a specific page's content starts and ends in the main content string,
 * enabling mapping from byte positions to page numbers. Offsets are guaranteed to be
 * at valid UTF-8 character boundaries when using standard String methods (push_str, push, etc.).
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = PageBoundary.Builder.class)
public record PageBoundary(
    /**
     * Byte offset where this page starts in the content string (UTF-8 valid boundary, inclusive)
     */
    @JsonProperty("byte_start") long byteStart,
    /**
     * Byte offset where this page ends in the content string (UTF-8 valid boundary, exclusive)
     */
    @JsonProperty("byte_end") long byteEnd,
    /**
     * Page number (1-indexed)
     */
    @JsonProperty("page_number") int pageNumber
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("byte_start")
private long byteStart = 0;
        @JsonProperty("byte_end")
private long byteEnd = 0;
        @JsonProperty("page_number")
private int pageNumber = 0;

        /** Sets the byteStart field. */
        @JsonProperty("byte_start")
        public Builder withByteStart(final long value) {
            this.byteStart = value;
            return this;
        }

        /** Sets the byteEnd field. */
        @JsonProperty("byte_end")
        public Builder withByteEnd(final long value) {
            this.byteEnd = value;
            return this;
        }

        /** Sets the pageNumber field. */
        @JsonProperty("page_number")
        public Builder withPageNumber(final int value) {
            this.pageNumber = value;
            return this;
        }

        /** Builds the PageBoundary instance. */
        public PageBoundary build() {
            return new PageBoundary(
                byteStart,
                byteEnd,
                pageNumber
            );
        }
    }
    // CPD-ON
}
