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 * One statement of a source unit. Its location is part of L1 (Section 12.2, rule 1). Generated from
010 * the schema definition Statement by scripts/sqllr/gen_type_model.py; do not edit.
011 *
012 * @since 4.2.17
013 */
014public final class Statement extends SqllrObject {
015
016    /** The members the schema defines, in schema order. */
017    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "sourceUnitRef", "ordinal", "start", "end", "operation", "analysisCompleteness", "featureCompleteness", "diagnosticRefs", "extensions"));
018
019    /** The members the schema requires. */
020    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "sourceUnitRef", "ordinal", "start", "end", "analysisCompleteness"));
021
022    /** Reads a JSON object as a {@code Statement}. */
023    public static final Reader<Statement> READER = new Reader<Statement>() {
024        @Override
025        public Statement read(Object json) {
026            return fromJson(json);
027        }
028    };
029
030    private Statement(Map<String, Object> members) {
031        super(members);
032    }
033
034    /** A {@code Statement} with the members of a JSON object, all kept. */
035    public static Statement fromJson(Object json) {
036        return new Statement(members(json, "Statement"));
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 ref}. A document-local reference: an integer that is unique across the
050     * whole document (one reference space for every object that carries a ref). Local references
051     * are assigned after merging and have no meaning outside the document (Sections 6.1 and 13).
052     * Null when absent; throws IllegalStateException when the member holds another JSON type.
053     */
054    public Long getRef() {
055        return integer("ref");
056    }
057
058    /**
059     * The member {@code sourceUnitRef}. A document-local reference: an integer that is unique
060     * across the whole document (one reference space for every object that carries a ref). Local
061     * references are assigned after merging and have no meaning outside the document (Sections 6.1
062     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
063     * type.
064     */
065    public Long getSourceUnitRef() {
066        return integer("sourceUnitRef");
067    }
068
069    /**
070     * The member {@code ordinal}. 0-based position of the statement within its source unit; with
071     * the unit identity it is the statement identity. A 0-based ordinal. Null when absent; throws
072     * IllegalStateException when the member holds another JSON type.
073     */
074    public Long getOrdinal() {
075        return integer("ordinal");
076    }
077
078    /**
079     * The member {@code start}. Null when absent; throws IllegalStateException when the member
080     * holds another JSON type.
081     */
082    public Position getStart() {
083        return typed("start", Position.READER);
084    }
085
086    /**
087     * The member {@code end}. Null when absent; throws IllegalStateException when the member holds
088     * another JSON type.
089     */
090    public Position getEnd() {
091        return typed("end", Position.READER);
092    }
093
094    /**
095     * The member {@code operation}. The kind of a statement. Registry group 'statementOperations'
096     * (Section 12.1). Null when absent; throws IllegalStateException when the member holds another
097     * JSON type.
098     */
099    public String getOperation() {
100        return string("operation");
101    }
102
103    /**
104     * The member {@code analysisCompleteness}. Analysis completeness of a scope. Registry group
105     * 'analysisCompleteness' (Section 4.4). Null when absent; throws IllegalStateException when the
106     * member holds another JSON type.
107     */
108    public String getAnalysisCompleteness() {
109        return string("analysisCompleteness");
110    }
111
112    /**
113     * The member {@code featureCompleteness}. Feature-scope completeness; one entry per feature.
114     * Null when absent; throws IllegalStateException when the member holds another JSON type.
115     */
116    public List<FeatureCompleteness> getFeatureCompleteness() {
117        return typed("featureCompleteness", listOf(FeatureCompleteness.READER));
118    }
119
120    /**
121     * The member {@code diagnosticRefs}. A set of local references. Null when absent; throws
122     * IllegalStateException when the member holds another JSON type.
123     */
124    public List<Long> getDiagnosticRefs() {
125        return typed("diagnosticRefs", listOf(INTEGER));
126    }
127
128    /**
129     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
130     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
131     * when the member holds another JSON type.
132     */
133    public Map<String, Extension> getExtensions() {
134        return typed("extensions", mapOf(Extension.READER));
135    }
136
137    /** Collects the members of a new {@code Statement}. */
138    public static final class Builder extends SqllrObject.Builder<Statement, Builder> {
139        private Builder(Map<String, Object> from) {
140            super(from);
141        }
142
143        /** Sets the member {@code ref}; null removes it. */
144        public Builder ref(Long value) {
145            return set("ref", value);
146        }
147
148        /** Sets the member {@code sourceUnitRef}; null removes it. */
149        public Builder sourceUnitRef(Long value) {
150            return set("sourceUnitRef", value);
151        }
152
153        /** Sets the member {@code ordinal}; null removes it. */
154        public Builder ordinal(Long value) {
155            return set("ordinal", value);
156        }
157
158        /** Sets the member {@code start}; null removes it. */
159        public Builder start(Position value) {
160            return set("start", value);
161        }
162
163        /** Sets the member {@code end}; null removes it. */
164        public Builder end(Position value) {
165            return set("end", value);
166        }
167
168        /** Sets the member {@code operation}; null removes it. */
169        public Builder operation(String value) {
170            return set("operation", value);
171        }
172
173        /** Sets the member {@code analysisCompleteness}; null removes it. */
174        public Builder analysisCompleteness(String value) {
175            return set("analysisCompleteness", value);
176        }
177
178        /** Sets the member {@code featureCompleteness}; null removes it. */
179        public Builder featureCompleteness(List<FeatureCompleteness> value) {
180            return set("featureCompleteness", value);
181        }
182
183        /** Sets the member {@code diagnosticRefs}; null removes it. */
184        public Builder diagnosticRefs(List<Long> value) {
185            return set("diagnosticRefs", value);
186        }
187
188        /** Sets the member {@code extensions}; null removes it. */
189        public Builder extensions(Map<String, Extension> value) {
190            return set("extensions", value);
191        }
192
193        @Override
194        public Statement build() {
195            return new Statement(frozenMembers());
196        }
197    }
198}