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 analysis context (Sections 6.2 and 9.2): the producer, dialect, dependency snapshot, options, 010 * metadata, redaction and capabilities under which an analysis asserted the content of the source 011 * units that name it. A document one analysis produced has one; a merged document keeps the context 012 * of every input unchanged. Generated from the schema definition AnalysisContext by 013 * scripts/sqllr/gen_type_model.py; do not edit. 014 * 015 * @since 4.2.17 016 */ 017public final class AnalysisContext extends SqllrObject { 018 019 /** The members the schema defines, in schema order. */ 020 public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "producer", "dialect", "identifierPolicy", "dependencySnapshotId", "pathProfile", "effectiveOptionsDigest", "metadata", "capabilities", "redaction", "extensions")); 021 022 /** The members the schema requires. */ 023 public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "producer", "dialect", "identifierPolicy", "dependencySnapshotId", "pathProfile", "effectiveOptionsDigest", "metadata", "capabilities", "redaction")); 024 025 /** Reads a JSON object as a {@code AnalysisContext}. */ 026 public static final Reader<AnalysisContext> READER = new Reader<AnalysisContext>() { 027 @Override 028 public AnalysisContext read(Object json) { 029 return fromJson(json); 030 } 031 }; 032 033 private AnalysisContext(Map<String, Object> members) { 034 super(members); 035 } 036 037 /** A {@code AnalysisContext} with the members of a JSON object, all kept. */ 038 public static AnalysisContext fromJson(Object json) { 039 return new AnalysisContext(members(json, "AnalysisContext")); 040 } 041 042 public static Builder builder() { 043 return new Builder(null); 044 } 045 046 /** A builder holding every member of this object. */ 047 public Builder toBuilder() { 048 return new Builder(toJson()); 049 } 050 051 /** 052 * The member {@code ref}. A document-local reference: an integer that is unique across the 053 * whole document (one reference space for every object that carries a ref). Local references 054 * are assigned after merging and have no meaning outside the document (Sections 6.1 and 13). 055 * Null when absent; throws IllegalStateException when the member holds another JSON type. 056 */ 057 public Long getRef() { 058 return integer("ref"); 059 } 060 061 /** 062 * The member {@code producer}. The producer that ran the analysis. Null when absent; throws 063 * IllegalStateException when the member holds another JSON type. 064 */ 065 public Producer getProducer() { 066 return typed("producer", Producer.READER); 067 } 068 069 /** 070 * The member {@code dialect}. Null when absent; throws IllegalStateException when the member 071 * holds another JSON type. 072 */ 073 public Dialect getDialect() { 074 return typed("dialect", Dialect.READER); 075 } 076 077 /** 078 * The member {@code identifierPolicy}. Null when absent; throws IllegalStateException when the 079 * member holds another JSON type. 080 */ 081 public IdentifierPolicy getIdentifierPolicy() { 082 return typed("identifierPolicy", IdentifierPolicy.READER); 083 } 084 085 /** 086 * The member {@code dependencySnapshotId}. The immutable dependency snapshot used: identifier 087 * rules, Unicode version, rule switches, collations, identity algorithms, registry and profiles 088 * (Section 14.3, item 3). An id computed by DependencySnapshotIdV1: 'snap1-' followed by 64 089 * lowercase hexadecimal characters of a SHA-256 digest (algorithms/identity-v1.md, Section 5.9; 090 * snapshots/FORMAT.md). Null when absent; throws IllegalStateException when the member holds 091 * another JSON type. 092 */ 093 public String getDependencySnapshotId() { 094 return string("dependencySnapshotId"); 095 } 096 097 /** 098 * The member {@code pathProfile}. The semantic path profile of every path the analysis wrote; 099 * 'sqllr-path-1' for the profile of this specification, otherwise a producer-declared id. Null 100 * when absent; throws IllegalStateException when the member holds another JSON type. 101 */ 102 public String getPathProfile() { 103 return string("pathProfile"); 104 } 105 106 /** 107 * The member {@code effectiveOptionsDigest}. SHA-256 of the canonical JSON (JCS mode) of the 108 * effective analysis options object after resolution; the digest of an empty options object 109 * when there are none. The options themselves belong to the module reproducibility. A SHA-256 110 * digest: 64 lowercase hexadecimal characters. Null when absent; throws IllegalStateException 111 * when the member holds another JSON type. 112 */ 113 public String getEffectiveOptionsDigest() { 114 return string("effectiveOptionsDigest"); 115 } 116 117 /** 118 * The member {@code metadata}. Null when absent; throws IllegalStateException when the member 119 * holds another JSON type. 120 */ 121 public Metadata getMetadata() { 122 return typed("metadata", Metadata.READER); 123 } 124 125 /** 126 * The member {@code capabilities}. The capability matrix: one value per feature. VALUE and ROW 127 * are always declared; a producer that does not support ROW declares UNSUPPORTED and never 128 * presents the absence of ROW Facts as COMPLETE (Section 5.3). Null when absent; throws 129 * IllegalStateException when the member holds another JSON type. 130 */ 131 public Map<String, Object> getCapabilities() { 132 return object("capabilities"); 133 } 134 135 /** 136 * The member {@code redaction}. Null when absent; throws IllegalStateException when the member 137 * holds another JSON type. 138 */ 139 public Redaction getRedaction() { 140 return typed("redaction", Redaction.READER); 141 } 142 143 /** 144 * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry 145 * it; it never takes part in a core identity. Null when absent; throws IllegalStateException 146 * when the member holds another JSON type. 147 */ 148 public Map<String, Extension> getExtensions() { 149 return typed("extensions", mapOf(Extension.READER)); 150 } 151 152 /** Collects the members of a new {@code AnalysisContext}. */ 153 public static final class Builder extends SqllrObject.Builder<AnalysisContext, Builder> { 154 private Builder(Map<String, Object> from) { 155 super(from); 156 } 157 158 /** Sets the member {@code ref}; null removes it. */ 159 public Builder ref(Long value) { 160 return set("ref", value); 161 } 162 163 /** Sets the member {@code producer}; null removes it. */ 164 public Builder producer(Producer value) { 165 return set("producer", value); 166 } 167 168 /** Sets the member {@code dialect}; null removes it. */ 169 public Builder dialect(Dialect value) { 170 return set("dialect", value); 171 } 172 173 /** Sets the member {@code identifierPolicy}; null removes it. */ 174 public Builder identifierPolicy(IdentifierPolicy value) { 175 return set("identifierPolicy", value); 176 } 177 178 /** Sets the member {@code dependencySnapshotId}; null removes it. */ 179 public Builder dependencySnapshotId(String value) { 180 return set("dependencySnapshotId", value); 181 } 182 183 /** Sets the member {@code pathProfile}; null removes it. */ 184 public Builder pathProfile(String value) { 185 return set("pathProfile", value); 186 } 187 188 /** Sets the member {@code effectiveOptionsDigest}; null removes it. */ 189 public Builder effectiveOptionsDigest(String value) { 190 return set("effectiveOptionsDigest", value); 191 } 192 193 /** Sets the member {@code metadata}; null removes it. */ 194 public Builder metadata(Metadata value) { 195 return set("metadata", value); 196 } 197 198 /** Sets the member {@code capabilities}; null removes it. */ 199 public Builder capabilities(Map<String, Object> value) { 200 return set("capabilities", value); 201 } 202 203 /** Sets the member {@code redaction}; null removes it. */ 204 public Builder redaction(Redaction value) { 205 return set("redaction", value); 206 } 207 208 /** Sets the member {@code extensions}; null removes it. */ 209 public Builder extensions(Map<String, Extension> value) { 210 return set("extensions", value); 211 } 212 213 @Override 214 public AnalysisContext build() { 215 return new AnalysisContext(frozenMembers()); 216 } 217 } 218}