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 typed diagnostic (Section 6.5). Its message is produced under redaction. Generated from the 010 * schema definition Diagnostic by scripts/sqllr/gen_type_model.py; do not edit. 011 * 012 * @since 4.2.17 013 */ 014public final class Diagnostic extends SqllrObject { 015 016 /** The members the schema defines, in schema order. */ 017 public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "code", "severity", "stage", "subjectRefs", "span", "recoverable", "producerCode", "message", "extensions")); 018 019 /** The members the schema requires. */ 020 public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "code", "severity", "recoverable")); 021 022 /** Reads a JSON object as a {@code Diagnostic}. */ 023 public static final Reader<Diagnostic> READER = new Reader<Diagnostic>() { 024 @Override 025 public Diagnostic read(Object json) { 026 return fromJson(json); 027 } 028 }; 029 030 private Diagnostic(Map<String, Object> members) { 031 super(members); 032 } 033 034 /** A {@code Diagnostic} with the members of a JSON object, all kept. */ 035 public static Diagnostic fromJson(Object json) { 036 return new Diagnostic(members(json, "Diagnostic")); 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 code}. A diagnostic code. Registry group 'diagnosticCodes' (Sections 5.3, 060 * 6.5, 7.7, 9.7, 14.2 and 17.1). Null when absent; throws IllegalStateException when the member 061 * holds another JSON type. 062 */ 063 public String getCode() { 064 return string("code"); 065 } 066 067 /** 068 * The member {@code severity}. The severity of a diagnostic. Registry group 069 * 'diagnosticSeverity' (Section 6.5). Null when absent; throws IllegalStateException when the 070 * member holds another JSON type. 071 */ 072 public String getSeverity() { 073 return string("severity"); 074 } 075 076 /** 077 * The member {@code stage}. The validation stage, for a diagnostic produced by validation. A 078 * validation stage. Registry group 'validationStages' (Sections 14.2 and 17.1). Null when 079 * absent; throws IllegalStateException when the member holds another JSON type. 080 */ 081 public String getStage() { 082 return string("stage"); 083 } 084 085 /** 086 * The member {@code subjectRefs}. The objects the diagnostic belongs to; absent when it belongs 087 * to the document. A set of local references. Null when absent; throws IllegalStateException 088 * when the member holds another JSON type. 089 */ 090 public List<Long> getSubjectRefs() { 091 return typed("subjectRefs", listOf(INTEGER)); 092 } 093 094 /** 095 * The member {@code span}. The location. Null when absent; throws IllegalStateException when 096 * the member holds another JSON type. 097 */ 098 public Span getSpan() { 099 return typed("span", Span.READER); 100 } 101 102 /** 103 * The member {@code recoverable}. Whether the analysis or operation recovered and continued. 104 * Null when absent; throws IllegalStateException when the member holds another JSON type. 105 */ 106 public Boolean getRecoverable() { 107 return bool("recoverable"); 108 } 109 110 /** 111 * The member {@code producerCode}. A producer-specific code that refines code. Null when 112 * absent; throws IllegalStateException when the member holds another JSON type. 113 */ 114 public String getProducerCode() { 115 return string("producerCode"); 116 } 117 118 /** 119 * The member {@code message}. A human-readable message; not normative. Null when absent; throws 120 * IllegalStateException when the member holds another JSON type. 121 */ 122 public String getMessage() { 123 return string("message"); 124 } 125 126 /** 127 * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry 128 * it; it never takes part in a core identity. Null when absent; throws IllegalStateException 129 * when the member holds another JSON type. 130 */ 131 public Map<String, Extension> getExtensions() { 132 return typed("extensions", mapOf(Extension.READER)); 133 } 134 135 /** Collects the members of a new {@code Diagnostic}. */ 136 public static final class Builder extends SqllrObject.Builder<Diagnostic, Builder> { 137 private Builder(Map<String, Object> from) { 138 super(from); 139 } 140 141 /** Sets the member {@code ref}; null removes it. */ 142 public Builder ref(Long value) { 143 return set("ref", value); 144 } 145 146 /** Sets the member {@code code}; null removes it. */ 147 public Builder code(String value) { 148 return set("code", value); 149 } 150 151 /** Sets the member {@code severity}; null removes it. */ 152 public Builder severity(String value) { 153 return set("severity", value); 154 } 155 156 /** Sets the member {@code stage}; null removes it. */ 157 public Builder stage(String value) { 158 return set("stage", value); 159 } 160 161 /** Sets the member {@code subjectRefs}; null removes it. */ 162 public Builder subjectRefs(List<Long> value) { 163 return set("subjectRefs", value); 164 } 165 166 /** Sets the member {@code span}; null removes it. */ 167 public Builder span(Span value) { 168 return set("span", value); 169 } 170 171 /** Sets the member {@code recoverable}; null removes it. */ 172 public Builder recoverable(Boolean value) { 173 return set("recoverable", value); 174 } 175 176 /** Sets the member {@code producerCode}; null removes it. */ 177 public Builder producerCode(String value) { 178 return set("producerCode", value); 179 } 180 181 /** Sets the member {@code message}; null removes it. */ 182 public Builder message(String value) { 183 return set("message", value); 184 } 185 186 /** Sets the member {@code extensions}; null removes it. */ 187 public Builder extensions(Map<String, Extension> value) { 188 return set("extensions", value); 189 } 190 191 @Override 192 public Diagnostic build() { 193 return new Diagnostic(frozenMembers()); 194 } 195 } 196}