// 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;
import org.jspecify.annotations.Nullable;

/**
 * Header/heading element metadata.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = HeaderMetadata.Builder.class)
public record HeaderMetadata(
    /**
     * Header level: 1 (h1) through 6 (h6)
     */
    @JsonProperty("level") byte level,
    /**
     * Normalized text content of the header
     */
    @JsonProperty("text") String text,
    /**
     * HTML id attribute if present
     */
    @Nullable @JsonProperty("id") String id,
    /**
     * Document tree depth at the header element
     */
    @JsonProperty("depth") int depth,
    /**
     * Byte offset in original HTML document
     */
    @JsonProperty("html_offset") int htmlOffset
) {
    public static Builder builder() {
        return new Builder();
    }

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

private byte level = 0;
private String text = "";
private String id = null;
private int depth = 0;
        @JsonProperty("html_offset")
private int htmlOffset = 0;

        /** Sets the level field. */
        @JsonProperty("level")
        public Builder withLevel(final byte value) {
            this.level = value;
            return this;
        }

        /** Sets the text field. */
        @JsonProperty("text")
        public Builder withText(final String value) {
            this.text = value;
            return this;
        }

        /** Sets the id field. */
        @JsonProperty("id")
        public Builder withId(final @Nullable String value) {
            this.id = value;
            return this;
        }

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

        /** Sets the htmlOffset field. */
        @JsonProperty("html_offset")
        public Builder withHtmlOffset(final int value) {
            this.htmlOffset = value;
            return this;
        }

        /** Builds the HeaderMetadata instance. */
        public HeaderMetadata build() {
            return new HeaderMetadata(
                level,
                text,
                id,
                depth,
                htmlOffset
            );
        }
    }
    // CPD-ON
}
