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 assertion of a Fact or FactCandidate by one statement in one analysis (Sections 3.1, 4.1, 4.2
010 * and 9.2). Generated from the schema definition Occurrence by scripts/sqllr/gen_type_model.py; do
011 * not edit.
012 *
013 * @since 4.2.17
014 */
015public final class Occurrence extends SqllrObject {
016
017    /** The members the schema defines, in schema order. */
018    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "factRef", "factCandidateRef", "statementRef", "path", "ordinal", "proofStatus", "sourceBinding", "targetBinding", "key", "recordId", "supportPathRefs", "evidenceRefs", "diagnosticRefs", "extensions"));
019
020    /** The members the schema requires. */
021    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "statementRef", "path", "ordinal", "proofStatus", "sourceBinding", "targetBinding"));
022
023    /** Reads a JSON object as a {@code Occurrence}. */
024    public static final Reader<Occurrence> READER = new Reader<Occurrence>() {
025        @Override
026        public Occurrence read(Object json) {
027            return fromJson(json);
028        }
029    };
030
031    private Occurrence(Map<String, Object> members) {
032        super(members);
033    }
034
035    /** A {@code Occurrence} with the members of a JSON object, all kept. */
036    public static Occurrence fromJson(Object json) {
037        return new Occurrence(members(json, "Occurrence"));
038    }
039
040    public static Builder builder() {
041        return new Builder(null);
042    }
043
044    /** A builder holding every member of this object. */
045    public Builder toBuilder() {
046        return new Builder(toJson());
047    }
048
049    /**
050     * The member {@code ref}. A document-local reference: an integer that is unique across the
051     * whole document (one reference space for every object that carries a ref). Local references
052     * are assigned after merging and have no meaning outside the document (Sections 6.1 and 13).
053     * Null when absent; throws IllegalStateException when the member holds another JSON type.
054     */
055    public Long getRef() {
056        return integer("ref");
057    }
058
059    /**
060     * The member {@code factRef}. A document-local reference: an integer that is unique across the
061     * whole document (one reference space for every object that carries a ref). Local references
062     * are assigned after merging and have no meaning outside the document (Sections 6.1 and 13).
063     * Null when absent; throws IllegalStateException when the member holds another JSON type.
064     */
065    public Long getFactRef() {
066        return integer("factRef");
067    }
068
069    /**
070     * The member {@code factCandidateRef}. A document-local reference: an integer that is unique
071     * across the whole document (one reference space for every object that carries a ref). Local
072     * references are assigned after merging and have no meaning outside the document (Sections 6.1
073     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
074     * type.
075     */
076    public Long getFactCandidateRef() {
077        return integer("factCandidateRef");
078    }
079
080    /**
081     * The member {@code statementRef}. A document-local reference: an integer that is unique across
082     * the whole document (one reference space for every object that carries a ref). Local
083     * references are assigned after merging and have no meaning outside the document (Sections 6.1
084     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
085     * type.
086     */
087    public Long getStatementRef() {
088        return integer("statementRef");
089    }
090
091    /**
092     * The member {@code path}. A semantic path. Under the path profile sqllr-path-1 it is a
093     * '/'-joined list of steps CODE[index] (registry group pathStepCodes) that follows
094     * algorithms/path-v1.md (semantic stage: SEMANTIC_PATH_PROFILE_VIOLATION); under another
095     * declared profile it is opaque and comparable only within (producer, path profile). Null when
096     * absent; throws IllegalStateException when the member holds another JSON type.
097     */
098    public String getPath() {
099        return string("path");
100    }
101
102    /**
103     * The member {@code ordinal}. The 0-based rank of this Occurrence among the Occurrences of the
104     * same statement with the same subject (Fact or FactCandidate) and the same path, by the start
105     * position of the reference it asserts (algorithms/identity-v1.md, Section 5.4). A 0-based
106     * ordinal. Null when absent; throws IllegalStateException when the member holds another JSON
107     * type.
108     */
109    public Long getOrdinal() {
110        return integer("ordinal");
111    }
112
113    /**
114     * The member {@code proofStatus}. The proof status of an Occurrence. Registry group
115     * 'proofStatus' (Section 4.1). Null when absent; throws IllegalStateException when the member
116     * holds another JSON type.
117     */
118    public String getProofStatus() {
119        return string("proofStatus");
120    }
121
122    /**
123     * The member {@code sourceBinding}. Null when absent; throws IllegalStateException when the
124     * member holds another JSON type.
125     */
126    public Binding getSourceBinding() {
127        return typed("sourceBinding", Binding.READER);
128    }
129
130    /**
131     * The member {@code targetBinding}. Null when absent; throws IllegalStateException when the
132     * member holds another JSON type.
133     */
134    public Binding getTargetBinding() {
135        return typed("targetBinding", Binding.READER);
136    }
137
138    /**
139     * The member {@code key}. The logical Occurrence key (OccurrenceKeyV1); absent when the source
140     * unit has no unitId or the subject has no portable identity. An id computed by
141     * OccurrenceKeyV1: 'occk1-' followed by 64 lowercase hexadecimal characters of a SHA-256 digest
142     * (algorithms/identity-v1.md). Null when absent; throws IllegalStateException when the member
143     * holds another JSON type.
144     */
145    public String getKey() {
146        return string("key");
147    }
148
149    /**
150     * The member {@code recordId}. The assertion record id (OccurrenceRecordIdV1 over key and the
151     * source unit's analysisContextId); absent when key or analysisContextId is absent. An id
152     * computed by OccurrenceRecordIdV1, the assertion record id: 'occr1-' followed by 64 lowercase
153     * hexadecimal characters of a SHA-256 digest (algorithms/identity-v1.md). Null when absent;
154     * throws IllegalStateException when the member holds another JSON type.
155     */
156    public String getRecordId() {
157        return string("recordId");
158    }
159
160    /**
161     * The member {@code supportPathRefs}. The ExplainGraph support paths that together cover the
162     * support subgraph of this Occurrence (algorithms/fold-v1.md, Section 8.2). Module explain. A
163     * set of local references. Null when absent; throws IllegalStateException when the member holds
164     * another JSON type.
165     */
166    public List<Long> getSupportPathRefs() {
167        return typed("supportPathRefs", listOf(INTEGER));
168    }
169
170    /**
171     * The member {@code evidenceRefs}. Evidence objects. Module evidence. A set of local
172     * references. Null when absent; throws IllegalStateException when the member holds another JSON
173     * type.
174     */
175    public List<Long> getEvidenceRefs() {
176        return typed("evidenceRefs", listOf(INTEGER));
177    }
178
179    /**
180     * The member {@code diagnosticRefs}. A set of local references. Null when absent; throws
181     * IllegalStateException when the member holds another JSON type.
182     */
183    public List<Long> getDiagnosticRefs() {
184        return typed("diagnosticRefs", listOf(INTEGER));
185    }
186
187    /**
188     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
189     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
190     * when the member holds another JSON type.
191     */
192    public Map<String, Extension> getExtensions() {
193        return typed("extensions", mapOf(Extension.READER));
194    }
195
196    /** Collects the members of a new {@code Occurrence}. */
197    public static final class Builder extends SqllrObject.Builder<Occurrence, Builder> {
198        private Builder(Map<String, Object> from) {
199            super(from);
200        }
201
202        /** Sets the member {@code ref}; null removes it. */
203        public Builder ref(Long value) {
204            return set("ref", value);
205        }
206
207        /** Sets the member {@code factRef}; null removes it. */
208        public Builder factRef(Long value) {
209            return set("factRef", value);
210        }
211
212        /** Sets the member {@code factCandidateRef}; null removes it. */
213        public Builder factCandidateRef(Long value) {
214            return set("factCandidateRef", value);
215        }
216
217        /** Sets the member {@code statementRef}; null removes it. */
218        public Builder statementRef(Long value) {
219            return set("statementRef", value);
220        }
221
222        /** Sets the member {@code path}; null removes it. */
223        public Builder path(String value) {
224            return set("path", value);
225        }
226
227        /** Sets the member {@code ordinal}; null removes it. */
228        public Builder ordinal(Long value) {
229            return set("ordinal", value);
230        }
231
232        /** Sets the member {@code proofStatus}; null removes it. */
233        public Builder proofStatus(String value) {
234            return set("proofStatus", value);
235        }
236
237        /** Sets the member {@code sourceBinding}; null removes it. */
238        public Builder sourceBinding(Binding value) {
239            return set("sourceBinding", value);
240        }
241
242        /** Sets the member {@code targetBinding}; null removes it. */
243        public Builder targetBinding(Binding value) {
244            return set("targetBinding", value);
245        }
246
247        /** Sets the member {@code key}; null removes it. */
248        public Builder key(String value) {
249            return set("key", value);
250        }
251
252        /** Sets the member {@code recordId}; null removes it. */
253        public Builder recordId(String value) {
254            return set("recordId", value);
255        }
256
257        /** Sets the member {@code supportPathRefs}; null removes it. */
258        public Builder supportPathRefs(List<Long> value) {
259            return set("supportPathRefs", value);
260        }
261
262        /** Sets the member {@code evidenceRefs}; null removes it. */
263        public Builder evidenceRefs(List<Long> value) {
264            return set("evidenceRefs", value);
265        }
266
267        /** Sets the member {@code diagnosticRefs}; null removes it. */
268        public Builder diagnosticRefs(List<Long> value) {
269            return set("diagnosticRefs", value);
270        }
271
272        /** Sets the member {@code extensions}; null removes it. */
273        public Builder extensions(Map<String, Extension> value) {
274            return set("extensions", value);
275        }
276
277        @Override
278        public Occurrence build() {
279            return new Occurrence(frozenMembers());
280        }
281    }
282}