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 * How a reference is decided by another reference of the same statement (algorithms/fold-v1.md,
010 * Sections 4.3 and 7.1): when the deciding reference, whose candidate set is candidateSetRef,
011 * denotes the alternativeRef of a pair, this reference denotes the pair's candidateRef. A call that
012 * several routines fit is the case it exists for: the callee's candidate set lists the routines,
013 * and the candidate set of each parameter the call binds is decided by it. Every candidate of the
014 * decided set is in exactly one pair and an alternative in at most one; an alternative in no pair
015 * leaves the reference without a referent when the deciding reference denotes it. In
016 * explainGraph.candidateSets the deciding set is a set of explainGraph.candidateSets; at an end of
017 * a FactCandidate it is a set of the document's candidateSets, so that an L1 reader sees which ends
018 * of several FactCandidates go together; the deciding set is never itself decided (semantic stage:
019 * SEMANTIC_CANDIDATE_SET_INVALID). Generated from the schema definition CandidateDecision by
020 * scripts/sqllr/gen_type_model.py; do not edit.
021 *
022 * @since 4.2.17
023 */
024public final class CandidateDecision extends SqllrObject {
025
026    /** The members the schema defines, in schema order. */
027    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("candidateSetRef", "alignment", "extensions"));
028
029    /** The members the schema requires. */
030    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("candidateSetRef", "alignment"));
031
032    /** Reads a JSON object as a {@code CandidateDecision}. */
033    public static final Reader<CandidateDecision> READER = new Reader<CandidateDecision>() {
034        @Override
035        public CandidateDecision read(Object json) {
036            return fromJson(json);
037        }
038    };
039
040    private CandidateDecision(Map<String, Object> members) {
041        super(members);
042    }
043
044    /** A {@code CandidateDecision} with the members of a JSON object, all kept. */
045    public static CandidateDecision fromJson(Object json) {
046        return new CandidateDecision(members(json, "CandidateDecision"));
047    }
048
049    public static Builder builder() {
050        return new Builder(null);
051    }
052
053    /** A builder holding every member of this object. */
054    public Builder toBuilder() {
055        return new Builder(toJson());
056    }
057
058    /**
059     * The member {@code candidateSetRef}. A document-local reference: an integer that is unique
060     * across the whole document (one reference space for every object that carries a ref). Local
061     * references are assigned after merging and have no meaning outside the document (Sections 6.1
062     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
063     * type.
064     */
065    public Long getCandidateSetRef() {
066        return integer("candidateSetRef");
067    }
068
069    /**
070     * The member {@code alignment}. Null when absent; throws IllegalStateException when the member
071     * holds another JSON type.
072     */
073    public List<CandidateAlignment> getAlignment() {
074        return typed("alignment", listOf(CandidateAlignment.READER));
075    }
076
077    /**
078     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
079     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
080     * when the member holds another JSON type.
081     */
082    public Map<String, Extension> getExtensions() {
083        return typed("extensions", mapOf(Extension.READER));
084    }
085
086    /** Collects the members of a new {@code CandidateDecision}. */
087    public static final class Builder extends SqllrObject.Builder<CandidateDecision, Builder> {
088        private Builder(Map<String, Object> from) {
089            super(from);
090        }
091
092        /** Sets the member {@code candidateSetRef}; null removes it. */
093        public Builder candidateSetRef(Long value) {
094            return set("candidateSetRef", value);
095        }
096
097        /** Sets the member {@code alignment}; null removes it. */
098        public Builder alignment(List<CandidateAlignment> value) {
099            return set("alignment", value);
100        }
101
102        /** Sets the member {@code extensions}; null removes it. */
103        public Builder extensions(Map<String, Extension> value) {
104            return set("extensions", value);
105        }
106
107        @Override
108        public CandidateDecision build() {
109            return new CandidateDecision(frozenMembers());
110        }
111    }
112}