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 SQL-LR lineage document (specification Section 6). Generated from the schema root by 010 * scripts/sqllr/gen_type_model.py; do not edit. 011 * 012 * @since 4.2.17 013 */ 014public final class Document extends SqllrObject { 015 016 /** The members the schema defines, in schema order. */ 017 public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("specUri", "specVersion", "declaredLevel", "modules", "header", "analysisContexts", "sourceUnits", "statements", "scopes", "endpoints", "facts", "factCandidates", "candidateSets", "occurrences", "targetFieldOccurrences", "analysisCompleteness", "featureCompleteness", "servingCompleteness", "diagnostics", "merge", "extensions", "explainGraph", "evidence", "dynamicSqlSites", "expressionSpans", "reproducibilityManifest", "typedSteps", "routineCalls", "wildcardSelections", "structuralSignatures", "refinements", "naryFacts")); 018 019 /** The members the schema requires. */ 020 public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("specUri", "specVersion", "declaredLevel", "modules", "header", "analysisContexts", "sourceUnits", "statements", "scopes", "endpoints", "facts", "factCandidates", "occurrences", "targetFieldOccurrences", "analysisCompleteness", "servingCompleteness", "diagnostics")); 021 022 /** Reads a JSON object as a {@code Document}. */ 023 public static final Reader<Document> READER = new Reader<Document>() { 024 @Override 025 public Document read(Object json) { 026 return fromJson(json); 027 } 028 }; 029 030 private Document(Map<String, Object> members) { 031 super(members); 032 } 033 034 /** A {@code Document} with the members of a JSON object, all kept. */ 035 public static Document fromJson(Object json) { 036 return new Document(members(json, "Document")); 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 specUri}. The permanent URI of the specification, assigned at release. Null 050 * when absent; throws IllegalStateException when the member holds another JSON type. 051 */ 052 public String getSpecUri() { 053 return string("specUri"); 054 } 055 056 /** 057 * The member {@code specVersion}. The specification version. This schema accepts 0.1.x. Null 058 * when absent; throws IllegalStateException when the member holds another JSON type. 059 */ 060 public String getSpecVersion() { 061 return string("specVersion"); 062 } 063 064 /** 065 * The member {@code declaredLevel}. A producer conformance level. Registry group 'levels' 066 * (Section 5.1). Null when absent; throws IllegalStateException when the member holds another 067 * JSON type. 068 */ 069 public String getDeclaredLevel() { 070 return string("declaredLevel"); 071 } 072 073 /** 074 * The member {@code modules}. The optional modules the document carries. A consumer never 075 * treats a module that is not listed as an empty collection. Null when absent; throws 076 * IllegalStateException when the member holds another JSON type. 077 */ 078 public List<String> getModules() { 079 return typed("modules", listOf(STRING)); 080 } 081 082 /** 083 * The member {@code header}. Null when absent; throws IllegalStateException when the member 084 * holds another JSON type. 085 */ 086 public Header getHeader() { 087 return typed("header", Header.READER); 088 } 089 090 /** 091 * The member {@code analysisContexts}. The analysis contexts of the document (Sections 6.2 and 092 * 9.2). Every source unit names one. Null when absent; throws IllegalStateException when the 093 * member holds another JSON type. 094 */ 095 public List<AnalysisContext> getAnalysisContexts() { 096 return typed("analysisContexts", listOf(AnalysisContext.READER)); 097 } 098 099 /** 100 * The member {@code sourceUnits}. Null when absent; throws IllegalStateException when the 101 * member holds another JSON type. 102 */ 103 public List<SourceUnit> getSourceUnits() { 104 return typed("sourceUnits", listOf(SourceUnit.READER)); 105 } 106 107 /** 108 * The member {@code statements}. Null when absent; throws IllegalStateException when the member 109 * holds another JSON type. 110 */ 111 public List<Statement> getStatements() { 112 return typed("statements", listOf(Statement.READER)); 113 } 114 115 /** 116 * The member {@code scopes}. Null when absent; throws IllegalStateException when the member 117 * holds another JSON type. 118 */ 119 public List<Scope> getScopes() { 120 return typed("scopes", listOf(Scope.READER)); 121 } 122 123 /** 124 * The member {@code endpoints}. Null when absent; throws IllegalStateException when the member 125 * holds another JSON type. 126 */ 127 public List<Endpoint> getEndpoints() { 128 return typed("endpoints", listOf(Endpoint.READER)); 129 } 130 131 /** 132 * The member {@code facts}. Null when absent; throws IllegalStateException when the member 133 * holds another JSON type. 134 */ 135 public List<Fact> getFacts() { 136 return typed("facts", listOf(Fact.READER)); 137 } 138 139 /** 140 * The member {@code factCandidates}. Null when absent; throws IllegalStateException when the 141 * member holds another JSON type. 142 */ 143 public List<FactCandidate> getFactCandidates() { 144 return typed("factCandidates", listOf(FactCandidate.READER)); 145 } 146 147 /** 148 * The member {@code candidateSets}. The candidate sets of the ambiguous references at which a 149 * Fact keeps an Occurrence (Section 4.3, rule 1): a Fact that holds whichever candidate the 150 * reference denotes keeps the reference's CANDIDATE or UNRESOLVED binding, whose 151 * candidateSetRef names a set of this array. Its candidates are Endpoints; a candidate that is 152 * an ExplainGraph node is not listed, and the set is then INCOMPLETE. It also holds the 153 * deciding sets that the decidedBy of FactCandidate ends names (algorithms/fold-v1.md, Section 154 * 7.1, item 5): for a call that several routines fit, the ROUTINE endpoints of those routines. 155 * Null when absent; throws IllegalStateException when the member holds another JSON type. 156 */ 157 public List<CandidateSet> getCandidateSets() { 158 return typed("candidateSets", listOf(CandidateSet.READER)); 159 } 160 161 /** 162 * The member {@code occurrences}. Null when absent; throws IllegalStateException when the 163 * member holds another JSON type. 164 */ 165 public List<Occurrence> getOccurrences() { 166 return typed("occurrences", listOf(Occurrence.READER)); 167 } 168 169 /** 170 * The member {@code targetFieldOccurrences}. Null when absent; throws IllegalStateException 171 * when the member holds another JSON type. 172 */ 173 public List<TargetFieldOccurrence> getTargetFieldOccurrences() { 174 return typed("targetFieldOccurrences", listOf(TargetFieldOccurrence.READER)); 175 } 176 177 /** 178 * The member {@code analysisCompleteness}. Document-scope analysis completeness. Analysis 179 * completeness of a scope. Registry group 'analysisCompleteness' (Section 4.4). Null when 180 * absent; throws IllegalStateException when the member holds another JSON type. 181 */ 182 public String getAnalysisCompleteness() { 183 return string("analysisCompleteness"); 184 } 185 186 /** 187 * The member {@code featureCompleteness}. Feature-scope completeness; one entry per feature. 188 * Null when absent; throws IllegalStateException when the member holds another JSON type. 189 */ 190 public List<FeatureCompleteness> getFeatureCompleteness() { 191 return typed("featureCompleteness", listOf(FeatureCompleteness.READER)); 192 } 193 194 /** 195 * The member {@code servingCompleteness}. Null when absent; throws IllegalStateException when 196 * the member holds another JSON type. 197 */ 198 public ServingCompleteness getServingCompleteness() { 199 return typed("servingCompleteness", ServingCompleteness.READER); 200 } 201 202 /** 203 * The member {@code diagnostics}. Null when absent; throws IllegalStateException when the 204 * member holds another JSON type. 205 */ 206 public List<Diagnostic> getDiagnostics() { 207 return typed("diagnostics", listOf(Diagnostic.READER)); 208 } 209 210 /** 211 * The member {@code merge}. Merge provenance of a merged document: input digests and the 212 * conflict ledger (Sections 9.5 and 15.2). The analysis context of each input, with its 213 * dependency snapshot and redaction context, is in analysisContexts. Defined later. Module 214 * content, defined later. Open: members are not yet constrained; arrays inside it are SEQUENCE 215 * until the module defines them (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when 216 * absent; throws IllegalStateException when the member holds another JSON type. 217 */ 218 public Map<String, Object> getMerge() { 219 return object("merge"); 220 } 221 222 /** 223 * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry 224 * it; it never takes part in a core identity. Null when absent; throws IllegalStateException 225 * when the member holds another JSON type. 226 */ 227 public Map<String, Extension> getExtensions() { 228 return typed("extensions", mapOf(Extension.READER)); 229 } 230 231 /** 232 * The member {@code explainGraph}. The ExplainGraph (Sections 3.4 and 7.7). Module explain. 233 * Null when absent; throws IllegalStateException when the member holds another JSON type. 234 */ 235 public ExplainGraph getExplainGraph() { 236 return typed("explainGraph", ExplainGraph.READER); 237 } 238 239 /** 240 * The member {@code evidence}. Evidence objects. Module evidence, defined later. A collection 241 * of module content, defined later. Registered as a SET sorted by the ref of its elements; 242 * arrays inside its elements are SEQUENCE until the module defines them 243 * (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; throws 244 * IllegalStateException when the member holds another JSON type. 245 */ 246 public List<Map<String, Object>> getEvidence() { 247 return typed("evidence", listOf(OBJECT)); 248 } 249 250 /** 251 * The member {@code dynamicSqlSites}. Dynamic SQL sites, holes and proofs. Module dynamic-sql, 252 * defined later. A collection of module content, defined later. Registered as a SET sorted by 253 * the ref of its elements; arrays inside its elements are SEQUENCE until the module defines 254 * them (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; throws 255 * IllegalStateException when the member holds another JSON type. 256 */ 257 public List<Map<String, Object>> getDynamicSqlSites() { 258 return typed("dynamicSqlSites", listOf(OBJECT)); 259 } 260 261 /** 262 * The member {@code expressionSpans}. Expression-level spans. Module exact-spans, defined 263 * later. A collection of module content, defined later. Registered as a SET sorted by the ref 264 * of its elements; arrays inside its elements are SEQUENCE until the module defines them 265 * (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; throws 266 * IllegalStateException when the member holds another JSON type. 267 */ 268 public List<Map<String, Object>> getExpressionSpans() { 269 return typed("expressionSpans", listOf(OBJECT)); 270 } 271 272 /** 273 * The member {@code reproducibilityManifest}. All effective analysis options and the metadata 274 * digest. Module reproducibility, defined later. Module content, defined later. Open: members 275 * are not yet constrained; arrays inside it are SEQUENCE until the module defines them 276 * (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; throws 277 * IllegalStateException when the member holds another JSON type. 278 */ 279 public Map<String, Object> getReproducibilityManifest() { 280 return object("reproducibilityManifest"); 281 } 282 283 /** 284 * The member {@code typedSteps}. Typed steps and operand groups (Section 7.6). Module 285 * typed-steps, defined later. A collection of module content, defined later. Registered as a 286 * SET sorted by the ref of its elements; arrays inside its elements are SEQUENCE until the 287 * module defines them (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; 288 * throws IllegalStateException when the member holds another JSON type. 289 */ 290 public List<Map<String, Object>> getTypedSteps() { 291 return typed("typedSteps", listOf(OBJECT)); 292 } 293 294 /** 295 * The member {@code routineCalls}. Call sites and argument-to-parameter bindings (Section 7.3). 296 * Module routines, defined later. A collection of module content, defined later. Registered as 297 * a SET sorted by the ref of its elements; arrays inside its elements are SEQUENCE until the 298 * module defines them (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; 299 * throws IllegalStateException when the member holds another JSON type. 300 */ 301 public List<Map<String, Object>> getRoutineCalls() { 302 return typed("routineCalls", listOf(OBJECT)); 303 } 304 305 /** 306 * The member {@code wildcardSelections}. WildcardSelection objects (Section 7.5). Module 307 * wildcards, defined later. A collection of module content, defined later. Registered as a SET 308 * sorted by the ref of its elements; arrays inside its elements are SEQUENCE until the module 309 * defines them (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; throws 310 * IllegalStateException when the member holds another JSON type. 311 */ 312 public List<Map<String, Object>> getWildcardSelections() { 313 return typed("wildcardSelections", listOf(OBJECT)); 314 } 315 316 /** 317 * The member {@code structuralSignatures}. Structural signatures of ExplainGraph nodes. Module 318 * structural-signature, defined later. A collection of module content, defined later. 319 * Registered as a SET sorted by the ref of its elements; arrays inside its elements are 320 * SEQUENCE until the module defines them (algorithms/canonical-json-v1.md, Section 5, rule 5). 321 * Null when absent; throws IllegalStateException when the member holds another JSON type. 322 */ 323 public List<Map<String, Object>> getStructuralSignatures() { 324 return typed("structuralSignatures", listOf(OBJECT)); 325 } 326 327 /** 328 * The member {@code refinements}. Refinement records (Sections 3.2, rule 4, and 7.1). Module 329 * join-semantics, defined later. A collection of module content, defined later. Registered as a 330 * SET sorted by the ref of its elements; arrays inside its elements are SEQUENCE until the 331 * module defines them (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; 332 * throws IllegalStateException when the member holds another JSON type. 333 */ 334 public List<Map<String, Object>> getRefinements() { 335 return typed("refinements", listOf(OBJECT)); 336 } 337 338 /** 339 * The member {@code naryFacts}. N-ary Facts (Section 3.2, rule 3). Module nary-facts, defined 340 * later. A collection of module content, defined later. Registered as a SET sorted by the ref 341 * of its elements; arrays inside its elements are SEQUENCE until the module defines them 342 * (algorithms/canonical-json-v1.md, Section 5, rule 5). Null when absent; throws 343 * IllegalStateException when the member holds another JSON type. 344 */ 345 public List<Map<String, Object>> getNaryFacts() { 346 return typed("naryFacts", listOf(OBJECT)); 347 } 348 349 /** Reads a document with the strict reader of canonical-json-v1 (Section 3); does not validate. */ 350 public static Document parse(byte[] data) { 351 return fromJson(gudusoft.gsqlparser.lineage.v2.json.CanonicalJson.parse(data)); 352 } 353 354 /** The canonical bytes of the document: RFC 8785, every array in its registered order. */ 355 public byte[] toBytes() { 356 return gudusoft.gsqlparser.lineage.v2.json.CanonicalJson.documentBytes(toJson()); 357 } 358 359 /** Collects the members of a new {@code Document}. */ 360 public static final class Builder extends SqllrObject.Builder<Document, Builder> { 361 private Builder(Map<String, Object> from) { 362 super(from); 363 } 364 365 /** Sets the member {@code specUri}; null removes it. */ 366 public Builder specUri(String value) { 367 return set("specUri", value); 368 } 369 370 /** Sets the member {@code specVersion}; null removes it. */ 371 public Builder specVersion(String value) { 372 return set("specVersion", value); 373 } 374 375 /** Sets the member {@code declaredLevel}; null removes it. */ 376 public Builder declaredLevel(String value) { 377 return set("declaredLevel", value); 378 } 379 380 /** Sets the member {@code modules}; null removes it. */ 381 public Builder modules(List<String> value) { 382 return set("modules", value); 383 } 384 385 /** Sets the member {@code header}; null removes it. */ 386 public Builder header(Header value) { 387 return set("header", value); 388 } 389 390 /** Sets the member {@code analysisContexts}; null removes it. */ 391 public Builder analysisContexts(List<AnalysisContext> value) { 392 return set("analysisContexts", value); 393 } 394 395 /** Sets the member {@code sourceUnits}; null removes it. */ 396 public Builder sourceUnits(List<SourceUnit> value) { 397 return set("sourceUnits", value); 398 } 399 400 /** Sets the member {@code statements}; null removes it. */ 401 public Builder statements(List<Statement> value) { 402 return set("statements", value); 403 } 404 405 /** Sets the member {@code scopes}; null removes it. */ 406 public Builder scopes(List<Scope> value) { 407 return set("scopes", value); 408 } 409 410 /** Sets the member {@code endpoints}; null removes it. */ 411 public Builder endpoints(List<Endpoint> value) { 412 return set("endpoints", value); 413 } 414 415 /** Sets the member {@code facts}; null removes it. */ 416 public Builder facts(List<Fact> value) { 417 return set("facts", value); 418 } 419 420 /** Sets the member {@code factCandidates}; null removes it. */ 421 public Builder factCandidates(List<FactCandidate> value) { 422 return set("factCandidates", value); 423 } 424 425 /** Sets the member {@code candidateSets}; null removes it. */ 426 public Builder candidateSets(List<CandidateSet> value) { 427 return set("candidateSets", value); 428 } 429 430 /** Sets the member {@code occurrences}; null removes it. */ 431 public Builder occurrences(List<Occurrence> value) { 432 return set("occurrences", value); 433 } 434 435 /** Sets the member {@code targetFieldOccurrences}; null removes it. */ 436 public Builder targetFieldOccurrences(List<TargetFieldOccurrence> value) { 437 return set("targetFieldOccurrences", value); 438 } 439 440 /** Sets the member {@code analysisCompleteness}; null removes it. */ 441 public Builder analysisCompleteness(String value) { 442 return set("analysisCompleteness", value); 443 } 444 445 /** Sets the member {@code featureCompleteness}; null removes it. */ 446 public Builder featureCompleteness(List<FeatureCompleteness> value) { 447 return set("featureCompleteness", value); 448 } 449 450 /** Sets the member {@code servingCompleteness}; null removes it. */ 451 public Builder servingCompleteness(ServingCompleteness value) { 452 return set("servingCompleteness", value); 453 } 454 455 /** Sets the member {@code diagnostics}; null removes it. */ 456 public Builder diagnostics(List<Diagnostic> value) { 457 return set("diagnostics", value); 458 } 459 460 /** Sets the member {@code merge}; null removes it. */ 461 public Builder merge(Map<String, Object> value) { 462 return set("merge", value); 463 } 464 465 /** Sets the member {@code extensions}; null removes it. */ 466 public Builder extensions(Map<String, Extension> value) { 467 return set("extensions", value); 468 } 469 470 /** Sets the member {@code explainGraph}; null removes it. */ 471 public Builder explainGraph(ExplainGraph value) { 472 return set("explainGraph", value); 473 } 474 475 /** Sets the member {@code evidence}; null removes it. */ 476 public Builder evidence(List<Map<String, Object>> value) { 477 return set("evidence", value); 478 } 479 480 /** Sets the member {@code dynamicSqlSites}; null removes it. */ 481 public Builder dynamicSqlSites(List<Map<String, Object>> value) { 482 return set("dynamicSqlSites", value); 483 } 484 485 /** Sets the member {@code expressionSpans}; null removes it. */ 486 public Builder expressionSpans(List<Map<String, Object>> value) { 487 return set("expressionSpans", value); 488 } 489 490 /** Sets the member {@code reproducibilityManifest}; null removes it. */ 491 public Builder reproducibilityManifest(Map<String, Object> value) { 492 return set("reproducibilityManifest", value); 493 } 494 495 /** Sets the member {@code typedSteps}; null removes it. */ 496 public Builder typedSteps(List<Map<String, Object>> value) { 497 return set("typedSteps", value); 498 } 499 500 /** Sets the member {@code routineCalls}; null removes it. */ 501 public Builder routineCalls(List<Map<String, Object>> value) { 502 return set("routineCalls", value); 503 } 504 505 /** Sets the member {@code wildcardSelections}; null removes it. */ 506 public Builder wildcardSelections(List<Map<String, Object>> value) { 507 return set("wildcardSelections", value); 508 } 509 510 /** Sets the member {@code structuralSignatures}; null removes it. */ 511 public Builder structuralSignatures(List<Map<String, Object>> value) { 512 return set("structuralSignatures", value); 513 } 514 515 /** Sets the member {@code refinements}; null removes it. */ 516 public Builder refinements(List<Map<String, Object>> value) { 517 return set("refinements", value); 518 } 519 520 /** Sets the member {@code naryFacts}; null removes it. */ 521 public Builder naryFacts(List<Map<String, Object>> value) { 522 return set("naryFacts", value); 523 } 524 525 @Override 526 public Document build() { 527 return new Document(frozenMembers()); 528 } 529 } 530}