// 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 single tracked change embedded in a document.
 *
 * Populated by per-format extractors that understand change-tracking metadata
 * (DOCX {@code w:ins}/{@code w:del}/{@code w:rPrChange}, ODT {@code text:change-*}, …). Every
 * extractor defaults to {@code ExtractionResult.revisions = None} until a
 * format-specific implementation is added.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = DocumentRevision.Builder.class)
public record DocumentRevision(
    /**
     * Format-specific revision identifier.
     *
     * For DOCX this is the {@code w:id} attribute value on the change element
     * (e.g. {@code "42"}). When the attribute is absent a synthetic fallback is
     * generated ({@code "docx-ins-0"}, {@code "docx-del-3"}, …).
     */
    @JsonProperty("revision_id") String revisionId,
    /**
     * Display name of the author who made this change, when available.
     */
    @Nullable @JsonProperty("author") String author,
    /**
     * ISO-8601 timestamp of the change, when available.
     *
     * Stored as a plain string so this type remains FFI-friendly and
     * unconditionally available without the {@code chrono} optional dep.
     * DOCX populates this from the {@code w:date} attribute (e.g.
     * {@code "2024-03-15T10:30:00Z"}).
     */
    @Nullable @JsonProperty("timestamp") String timestamp,
    /**
     * Semantic kind of this revision.
     */
    @JsonProperty("kind") RevisionKind kind,
    /**
     * Best-effort document location for this revision.
     *
     * Resolution is format-dependent and may be {@code None} when the location
     * cannot be determined (e.g. changes inside table cells before
     * table-cell anchor support is added).
     */
    @Nullable @JsonProperty("anchor") RevisionAnchor anchor,
    /**
     * The content changes that make up this revision.
     */
    @JsonProperty("delta") RevisionDelta delta
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("revision_id")
private String revisionId = "";
private String author = null;
private String timestamp = null;
private RevisionKind kind = null;
private RevisionAnchor anchor = null;
private RevisionDelta delta = null;

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

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

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

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

        /** Sets the anchor field. */
        @JsonProperty("anchor")
        public Builder withAnchor(final @Nullable RevisionAnchor value) {
            this.anchor = value;
            return this;
        }

        /** Sets the delta field. */
        @JsonProperty("delta")
        public Builder withDelta(final RevisionDelta value) {
            this.delta = value;
            return this;
        }

        /** Builds the DocumentRevision instance. */
        public DocumentRevision build() {
            return new DocumentRevision(
                revisionId,
                author,
                timestamp,
                kind,
                anchor,
                delta
            );
        }
    }
    // CPD-ON
}
