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

/**
 * Page hierarchy structure containing heading levels and block information.
 *
 * Used when PDF text hierarchy extraction is enabled. Contains hierarchical
 * blocks with heading levels (H1-H6) for semantic document structure.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = PageHierarchy.Builder.class)
public record PageHierarchy(
    /**
     * Number of hierarchy blocks on this page
     */
    @JsonProperty("block_count") int blockCount,
    /**
     * Hierarchical blocks with heading levels
     */
    @Nullable @JsonProperty("blocks") List<HierarchicalBlock> blocks
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("block_count")
private int blockCount = 0;
private List<HierarchicalBlock> blocks = null;

        /** Sets the blockCount field. */
        @JsonProperty("block_count")
        public Builder withBlockCount(final int value) {
            this.blockCount = value;
            return this;
        }

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

        /** Builds the PageHierarchy instance. */
        public PageHierarchy build() {
            return new PageHierarchy(
                blockCount,
                blocks
            );
        }
    }
    // CPD-ON
}
