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 * The possible bindings of one unresolved or ambiguous reference (Sections 3.2 and 4.3), or, at an 010 * end of a FactCandidate that the fold derives, the endpoints its outcomes reach 011 * (algorithms/fold-v1.md, Section 7.1). A producer never picks one of them. Membership COMPLETE: 012 * the reference denotes one of the members, and there are at least two. Membership INCOMPLETE: it 013 * may also denote something not listed; any number of members, none for an UNRESOLVED reference 014 * (semantic stage: SEMANTIC_CANDIDATE_SET_INVALID). Generated from the schema definition 015 * CandidateSet by scripts/sqllr/gen_type_model.py; do not edit. 016 * 017 * @since 4.2.17 018 */ 019public final class CandidateSet extends SqllrObject { 020 021 /** The members the schema defines, in schema order. */ 022 public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "candidateRefs", "membership", "writtenText", "decidedBy", "details", "extensions")); 023 024 /** The members the schema requires. */ 025 public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "candidateRefs", "membership")); 026 027 /** Reads a JSON object as a {@code CandidateSet}. */ 028 public static final Reader<CandidateSet> READER = new Reader<CandidateSet>() { 029 @Override 030 public CandidateSet read(Object json) { 031 return fromJson(json); 032 } 033 }; 034 035 private CandidateSet(Map<String, Object> members) { 036 super(members); 037 } 038 039 /** A {@code CandidateSet} with the members of a JSON object, all kept. */ 040 public static CandidateSet fromJson(Object json) { 041 return new CandidateSet(members(json, "CandidateSet")); 042 } 043 044 public static Builder builder() { 045 return new Builder(null); 046 } 047 048 /** A builder holding every member of this object. */ 049 public Builder toBuilder() { 050 return new Builder(toJson()); 051 } 052 053 /** 054 * The member {@code ref}. A document-local reference: an integer that is unique across the 055 * whole document (one reference space for every object that carries a ref). Local references 056 * are assigned after merging and have no meaning outside the document (Sections 6.1 and 13). 057 * Null when absent; throws IllegalStateException when the member holds another JSON type. 058 */ 059 public Long getRef() { 060 return integer("ref"); 061 } 062 063 /** 064 * The member {@code candidateRefs}. Endpoints the reference may denote; empty for an UNRESOLVED 065 * reference. In explainGraph.candidateSets, the candidates of a reference to a column of an 066 * intermediate result are ExplainGraph nodes. Null when absent; throws IllegalStateException 067 * when the member holds another JSON type. 068 */ 069 public List<Long> getCandidateRefs() { 070 return typed("candidateRefs", listOf(INTEGER)); 071 } 072 073 /** 074 * The member {@code membership}. Whether a candidate set lists every possible binding. Registry 075 * group 'candidateSetCompleteness' (Sections 3.2 and 4.3). Null when absent; throws 076 * IllegalStateException when the member holds another JSON type. 077 */ 078 public String getMembership() { 079 return string("membership"); 080 } 081 082 /** 083 * The member {@code writtenText}. The reference as written, after redaction. Null when absent; 084 * throws IllegalStateException when the member holds another JSON type. 085 */ 086 public String getWrittenText() { 087 return string("writtenText"); 088 } 089 090 /** 091 * The member {@code decidedBy}. In explainGraph.candidateSets and at the ends of 092 * FactCandidates, never in the document's candidateSets: the reference is decided by another 093 * reference, and the set says how (algorithms/fold-v1.md, Sections 4.3 and 7.1). Null when 094 * absent; throws IllegalStateException when the member holds another JSON type. 095 */ 096 public CandidateDecision getDecidedBy() { 097 return typed("decidedBy", CandidateDecision.READER); 098 } 099 100 /** 101 * The member {@code details}. Candidate set details. Module evidence, defined later; open. Null 102 * when absent; throws IllegalStateException when the member holds another JSON type. 103 */ 104 public Map<String, Object> getDetails() { 105 return object("details"); 106 } 107 108 /** 109 * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry 110 * it; it never takes part in a core identity. Null when absent; throws IllegalStateException 111 * when the member holds another JSON type. 112 */ 113 public Map<String, Extension> getExtensions() { 114 return typed("extensions", mapOf(Extension.READER)); 115 } 116 117 /** Collects the members of a new {@code CandidateSet}. */ 118 public static final class Builder extends SqllrObject.Builder<CandidateSet, Builder> { 119 private Builder(Map<String, Object> from) { 120 super(from); 121 } 122 123 /** Sets the member {@code ref}; null removes it. */ 124 public Builder ref(Long value) { 125 return set("ref", value); 126 } 127 128 /** Sets the member {@code candidateRefs}; null removes it. */ 129 public Builder candidateRefs(List<Long> value) { 130 return set("candidateRefs", value); 131 } 132 133 /** Sets the member {@code membership}; null removes it. */ 134 public Builder membership(String value) { 135 return set("membership", value); 136 } 137 138 /** Sets the member {@code writtenText}; null removes it. */ 139 public Builder writtenText(String value) { 140 return set("writtenText", value); 141 } 142 143 /** Sets the member {@code decidedBy}; null removes it. */ 144 public Builder decidedBy(CandidateDecision value) { 145 return set("decidedBy", value); 146 } 147 148 /** Sets the member {@code details}; null removes it. */ 149 public Builder details(Map<String, Object> value) { 150 return set("details", value); 151 } 152 153 /** Sets the member {@code extensions}; null removes it. */ 154 public Builder extensions(Map<String, Extension> value) { 155 return set("extensions", value); 156 } 157 158 @Override 159 public CandidateSet build() { 160 return new CandidateSet(frozenMembers()); 161 } 162 } 163}