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

/**
 * Metadata for a semantic element.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ElementMetadata.Builder.class)
public record ElementMetadata(
    /**
     * Page number (1-indexed)
     */
    @Nullable @JsonProperty("page_number") Integer pageNumber,
    /**
     * Source filename or document name
     */
    @Nullable @JsonProperty("filename") String filename,
    /**
     * Bounding box coordinates if available
     */
    @Nullable @JsonProperty("coordinates") BoundingBox coordinates,
    /**
     * Position index in the element sequence
     */
    @Nullable @JsonProperty("element_index") Long elementIndex,
    /**
     * Additional custom metadata
     */
    @JsonProperty("additional") Map<String, String> additional
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("page_number")
private Integer pageNumber = null;
private String filename = null;
private BoundingBox coordinates = null;
        @JsonProperty("element_index")
private Long elementIndex = null;
private Map<String, String> additional = Map.of();

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

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

        /** Sets the coordinates field. */
        @JsonProperty("coordinates")
        public Builder withCoordinates(final @Nullable BoundingBox value) {
            this.coordinates = value;
            return this;
        }

        /** Sets the elementIndex field. */
        @JsonProperty("element_index")
        public Builder withElementIndex(final @Nullable long value) {
            this.elementIndex = value;
            return this;
        }

        /** Sets the additional field. */
        @JsonProperty("additional")
        public Builder withAdditional(final Map<String, String> value) {
            this.additional = value;
            return this;
        }

        /** Builds the ElementMetadata instance. */
        public ElementMetadata build() {
            return new ElementMetadata(
                pageNumber,
                filename,
                coordinates,
                elementIndex,
                additional
            );
        }
    }
    // CPD-ON
}
