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 * An edge of the ExplainGraph (algorithms/fold-v1.md, Sections 4.1 and 4.3). Kind VALUE (shape E1)
010 * or ROW with a role (shapes E2 to E5). Both ends belong to statementRef. Generated from the schema
011 * definition MicroEdge by scripts/sqllr/gen_type_model.py; do not edit.
012 *
013 * @since 4.2.17
014 */
015public final class MicroEdge extends SqllrObject {
016
017    /** The members the schema defines, in schema order. */
018    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "kind", "role", "statementRef", "sourceRef", "targetRef", "referencePath", "referenceStart", "sourceBinding", "targetBinding", "proofStatus", "effect", "diagnosticRefs", "extensions"));
019
020    /** The members the schema requires. */
021    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "kind", "statementRef", "sourceRef", "targetRef"));
022
023    /** Reads a JSON object as a {@code MicroEdge}. */
024    public static final Reader<MicroEdge> READER = new Reader<MicroEdge>() {
025        @Override
026        public MicroEdge read(Object json) {
027            return fromJson(json);
028        }
029    };
030
031    private MicroEdge(Map<String, Object> members) {
032        super(members);
033    }
034
035    /** A {@code MicroEdge} with the members of a JSON object, all kept. */
036    public static MicroEdge fromJson(Object json) {
037        return new MicroEdge(members(json, "MicroEdge"));
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 kind}. VALUE or ROW (registry group factKinds); other kinds are not
061     * micro-edges. Null when absent; throws IllegalStateException when the member holds another
062     * JSON type.
063     */
064    public String getKind() {
065        return string("kind");
066    }
067
068    /**
069     * The member {@code role}. The role of a ROW Fact. Registry group 'rowRoles' (Section 3.3).
070     * Null when absent; throws IllegalStateException when the member holds another JSON type.
071     */
072    public String getRole() {
073        return string("role");
074    }
075
076    /**
077     * The member {@code statementRef}. A document-local reference: an integer that is unique across
078     * the whole document (one reference space for every object that carries a ref). Local
079     * references are assigned after merging and have no meaning outside the document (Sections 6.1
080     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
081     * type.
082     */
083    public Long getStatementRef() {
084        return integer("statementRef");
085    }
086
087    /**
088     * The member {@code sourceRef}. An Endpoint, an ExplainGraph node, or the candidate set of an
089     * UNRESOLVED reference. A document-local reference: an integer that is unique across the whole
090     * document (one reference space for every object that carries a ref). Local references are
091     * assigned after merging and have no meaning outside the document (Sections 6.1 and 13). Null
092     * when absent; throws IllegalStateException when the member holds another JSON type.
093     */
094    public Long getSourceRef() {
095        return integer("sourceRef");
096    }
097
098    /**
099     * The member {@code targetRef}. An Endpoint or an ExplainGraph node other than a TERMINAL node.
100     * A document-local reference: an integer that is unique across the whole document (one
101     * reference space for every object that carries a ref). Local references are assigned after
102     * merging and have no meaning outside the document (Sections 6.1 and 13). Null when absent;
103     * throws IllegalStateException when the member holds another JSON type.
104     */
105    public Long getTargetRef() {
106        return integer("targetRef");
107    }
108
109    /**
110     * The member {@code referencePath}. The semantic path of the name reference the edge reads
111     * (when it has a sourceBinding), otherwise of the reference it writes. Gives the Occurrence
112     * path. A semantic path. Under the path profile sqllr-path-1 it is a '/'-joined list of steps
113     * CODE[index] (registry group pathStepCodes) that follows algorithms/path-v1.md (semantic
114     * stage: SEMANTIC_PATH_PROFILE_VIOLATION); under another declared profile it is opaque and
115     * comparable only within (producer, path profile). Null when absent; throws
116     * IllegalStateException when the member holds another JSON type.
117     */
118    public String getReferencePath() {
119        return string("referencePath");
120    }
121
122    /**
123     * The member {@code referenceStart}. The start of that reference in the statement's source
124     * unit. Orders Occurrences on one path; never part of a key. Null when absent; throws
125     * IllegalStateException when the member holds another JSON type.
126     */
127    public Position getReferenceStart() {
128        return typed("referenceStart", Position.READER);
129    }
130
131    /**
132     * The member {@code sourceBinding}. The binding of the reference the edge reads; on a first
133     * edge, the binding of the kept source. Null when absent; throws IllegalStateException when the
134     * member holds another JSON type.
135     */
136    public Binding getSourceBinding() {
137        return typed("sourceBinding", Binding.READER);
138    }
139
140    /**
141     * The member {@code targetBinding}. The binding of the reference the edge writes; only on an
142     * edge into a kept target. Null when absent; throws IllegalStateException when the member holds
143     * another JSON type.
144     */
145    public Binding getTargetBinding() {
146        return typed("targetBinding", Binding.READER);
147    }
148
149    /**
150     * The member {@code proofStatus}. ASSUMED when the producer could not prove the edge (for
151     * example an edge that a dynamic SQL hole may affect); absent means PROVEN. The proof status of
152     * an Occurrence. Registry group 'proofStatus' (Section 4.1). Null when absent; throws
153     * IllegalStateException when the member holds another JSON type.
154     */
155    public String getProofStatus() {
156        return string("proofStatus");
157    }
158
159    /**
160     * The member {@code effect}. Display and refinement only; the fold never reads it. An effect
161     * carried by a micro-edge or a refinement record. Registry group 'valueEffects' (Sections 7.1
162     * and 18, item 8). Null when absent; throws IllegalStateException when the member holds another
163     * JSON type.
164     */
165    public String getEffect() {
166        return string("effect");
167    }
168
169    /**
170     * The member {@code diagnosticRefs}. A set of local references. Null when absent; throws
171     * IllegalStateException when the member holds another JSON type.
172     */
173    public List<Long> getDiagnosticRefs() {
174        return typed("diagnosticRefs", listOf(INTEGER));
175    }
176
177    /**
178     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
179     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
180     * when the member holds another JSON type.
181     */
182    public Map<String, Extension> getExtensions() {
183        return typed("extensions", mapOf(Extension.READER));
184    }
185
186    /** Collects the members of a new {@code MicroEdge}. */
187    public static final class Builder extends SqllrObject.Builder<MicroEdge, Builder> {
188        private Builder(Map<String, Object> from) {
189            super(from);
190        }
191
192        /** Sets the member {@code ref}; null removes it. */
193        public Builder ref(Long value) {
194            return set("ref", value);
195        }
196
197        /** Sets the member {@code kind}; null removes it. */
198        public Builder kind(String value) {
199            return set("kind", value);
200        }
201
202        /** Sets the member {@code role}; null removes it. */
203        public Builder role(String value) {
204            return set("role", value);
205        }
206
207        /** Sets the member {@code statementRef}; null removes it. */
208        public Builder statementRef(Long value) {
209            return set("statementRef", value);
210        }
211
212        /** Sets the member {@code sourceRef}; null removes it. */
213        public Builder sourceRef(Long value) {
214            return set("sourceRef", value);
215        }
216
217        /** Sets the member {@code targetRef}; null removes it. */
218        public Builder targetRef(Long value) {
219            return set("targetRef", value);
220        }
221
222        /** Sets the member {@code referencePath}; null removes it. */
223        public Builder referencePath(String value) {
224            return set("referencePath", value);
225        }
226
227        /** Sets the member {@code referenceStart}; null removes it. */
228        public Builder referenceStart(Position value) {
229            return set("referenceStart", value);
230        }
231
232        /** Sets the member {@code sourceBinding}; null removes it. */
233        public Builder sourceBinding(Binding value) {
234            return set("sourceBinding", value);
235        }
236
237        /** Sets the member {@code targetBinding}; null removes it. */
238        public Builder targetBinding(Binding value) {
239            return set("targetBinding", value);
240        }
241
242        /** Sets the member {@code proofStatus}; null removes it. */
243        public Builder proofStatus(String value) {
244            return set("proofStatus", value);
245        }
246
247        /** Sets the member {@code effect}; null removes it. */
248        public Builder effect(String value) {
249            return set("effect", value);
250        }
251
252        /** Sets the member {@code diagnosticRefs}; null removes it. */
253        public Builder diagnosticRefs(List<Long> value) {
254            return set("diagnosticRefs", value);
255        }
256
257        /** Sets the member {@code extensions}; null removes it. */
258        public Builder extensions(Map<String, Extension> value) {
259            return set("extensions", value);
260        }
261
262        @Override
263        public MicroEdge build() {
264            return new MicroEdge(frozenMembers());
265        }
266    }
267}