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

/**
 * Extracted keyword with metadata.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = Keyword.Builder.class)
public record Keyword(
    /**
     * The keyword text.
     */
    @JsonProperty("text") String text,
    /**
     * Relevance score (higher is better, algorithm-specific range).
     */
    @JsonProperty("score") float score,
    /**
     * Algorithm that extracted this keyword.
     */
    @JsonProperty("algorithm") KeywordAlgorithm algorithm,
    /**
     * Optional positions where keyword appears in text (character offsets).
     */
    @Nullable @JsonProperty("positions") List<Long> positions
) {
    public static Builder builder() {
        return new Builder();
    }

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

private String text = "";
private float score = 0.0f;
private KeywordAlgorithm algorithm = null;
private List<Long> positions = null;

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

        /** Sets the score field. */
        @JsonProperty("score")
        public Builder withScore(final float value) {
            this.score = value;
            return this;
        }

        /** Sets the algorithm field. */
        @JsonProperty("algorithm")
        public Builder withAlgorithm(final KeywordAlgorithm value) {
            this.algorithm = value;
            return this;
        }

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

        /** Builds the Keyword instance. */
        public Keyword build() {
            return new Keyword(
                text,
                score,
                algorithm,
                positions
            );
        }
    }
    // CPD-ON
}
