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

/**
 * A URI extracted from a document.
 *
 * Represents any link, reference, or resource pointer found during extraction.
 * The {@code kind} field classifies the URI semantically, while {@code label} carries
 * optional human-readable display text.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = ExtractedUri.Builder.class)
public record ExtractedUri(
    /**
     * The URL or path string.
     */
    @JsonProperty("url") String url,
    /**
     * Optional display text / label for the link.
     */
    @Nullable @JsonProperty("label") String label,
    /**
     * Optional page number where the URI was found (1-indexed).
     */
    @Nullable @JsonProperty("page") Integer page,
    /**
     * Semantic classification of the URI.
     */
    @JsonProperty("kind") UriKind kind
) {
    public static Builder builder() {
        return new Builder();
    }

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

private String url = "";
private String label = null;
private Integer page = null;
private UriKind kind = null;

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

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

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

        /** Sets the kind field. */
        @JsonProperty("kind")
        public Builder withKind(final UriKind value) {
            this.kind = value;
            return this;
        }

        /** Builds the ExtractedUri instance. */
        public ExtractedUri build() {
            return new ExtractedUri(
                url,
                label,
                page,
                kind
            );
        }
    }
    // CPD-ON
}
