001package gudusoft.gsqlparser.lineage.v2.model;
002
003import java.util.Arrays;
004import java.util.Collections;
005import java.util.List;
006import java.util.Map;
007
008/**
009 * A half-open interval (start inclusive, end exclusive) of a source unit (Sections 7.8 and 12).
010 * Generated from the schema definition Span by scripts/sqllr/gen_type_model.py; do not edit.
011 *
012 * @since 4.2.17
013 */
014public final class Span extends SqllrObject {
015
016    /** The members the schema defines, in schema order. */
017    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("sourceUnitRef", "start", "end"));
018
019    /** The members the schema requires. */
020    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("sourceUnitRef", "start", "end"));
021
022    /** Reads a JSON object as a {@code Span}. */
023    public static final Reader<Span> READER = new Reader<Span>() {
024        @Override
025        public Span read(Object json) {
026            return fromJson(json);
027        }
028    };
029
030    private Span(Map<String, Object> members) {
031        super(members);
032    }
033
034    /** A {@code Span} with the members of a JSON object, all kept. */
035    public static Span fromJson(Object json) {
036        return new Span(members(json, "Span"));
037    }
038
039    public static Builder builder() {
040        return new Builder(null);
041    }
042
043    /** A builder holding every member of this object. */
044    public Builder toBuilder() {
045        return new Builder(toJson());
046    }
047
048    /**
049     * The member {@code sourceUnitRef}. A document-local reference: an integer that is unique
050     * across the whole document (one reference space for every object that carries a ref). Local
051     * references are assigned after merging and have no meaning outside the document (Sections 6.1
052     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
053     * type.
054     */
055    public Long getSourceUnitRef() {
056        return integer("sourceUnitRef");
057    }
058
059    /**
060     * The member {@code start}. Null when absent; throws IllegalStateException when the member
061     * holds another JSON type.
062     */
063    public Position getStart() {
064        return typed("start", Position.READER);
065    }
066
067    /**
068     * The member {@code end}. Null when absent; throws IllegalStateException when the member holds
069     * another JSON type.
070     */
071    public Position getEnd() {
072        return typed("end", Position.READER);
073    }
074
075    /** Collects the members of a new {@code Span}. */
076    public static final class Builder extends SqllrObject.Builder<Span, Builder> {
077        private Builder(Map<String, Object> from) {
078            super(from);
079        }
080
081        /** Sets the member {@code sourceUnitRef}; null removes it. */
082        public Builder sourceUnitRef(Long value) {
083            return set("sourceUnitRef", value);
084        }
085
086        /** Sets the member {@code start}; null removes it. */
087        public Builder start(Position value) {
088            return set("start", value);
089        }
090
091        /** Sets the member {@code end}; null removes it. */
092        public Builder end(Position value) {
093            return set("end", value);
094        }
095
096        @Override
097        public Span build() {
098            return new Span(frozenMembers());
099        }
100    }
101}