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 quarantined proposition whose endpoint binding is not sufficient to publish a Fact (Section
010 * 3.2, rule 2). It is not a lower-confidence Fact and is never merged with a Fact. Either end may
011 * be a candidate set; outcomes records which sources and targets go together when the ends alone do
012 * not (algorithms/fold-v1.md, Section 7.1). Generated from the schema definition FactCandidate by
013 * scripts/sqllr/gen_type_model.py; do not edit.
014 *
015 * @since 4.2.17
016 */
017public final class FactCandidate extends SqllrObject {
018
019    /** The members the schema defines, in schema order. */
020    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "kind", "role", "source", "target", "outcomes", "extensions"));
021
022    /** The members the schema requires. */
023    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "kind", "source", "target"));
024
025    /** Reads a JSON object as a {@code FactCandidate}. */
026    public static final Reader<FactCandidate> READER = new Reader<FactCandidate>() {
027        @Override
028        public FactCandidate read(Object json) {
029            return fromJson(json);
030        }
031    };
032
033    private FactCandidate(Map<String, Object> members) {
034        super(members);
035    }
036
037    /** A {@code FactCandidate} with the members of a JSON object, all kept. */
038    public static FactCandidate fromJson(Object json) {
039        return new FactCandidate(members(json, "FactCandidate"));
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 kind}. A Fact kind. Registry group 'factKinds' (Section 3.3). Null when
063     * absent; throws IllegalStateException when the member holds another JSON type.
064     */
065    public String getKind() {
066        return string("kind");
067    }
068
069    /**
070     * The member {@code role}. The role of a ROW Fact. Registry group 'rowRoles' (Section 3.3).
071     * Null when absent; throws IllegalStateException when the member holds another JSON type.
072     */
073    public String getRole() {
074        return string("role");
075    }
076
077    /**
078     * The member {@code source}. Null when absent; throws IllegalStateException when the member
079     * holds another JSON type.
080     */
081    public CandidateEnd getSource() {
082        return typed("source", CandidateEnd.READER);
083    }
084
085    /**
086     * The member {@code target}. Null when absent; throws IllegalStateException when the member
087     * holds another JSON type.
088     */
089    public CandidateEnd getTarget() {
090        return typed("target", CandidateEnd.READER);
091    }
092
093    /**
094     * The member {@code outcomes}. The outcomes of the candidate, present only when they are not
095     * the implied ones (each pair of a source member and a target member on its own). Each outcome
096     * is the set of (source, target) pairs that hold together under one choice of the ambiguous
097     * references the candidate depends on; exactly one outcome holds when every candidate-set end
098     * is COMPLETE, at most one otherwise (algorithms/fold-v1.md, Section 7.1). Null when absent;
099     * throws IllegalStateException when the member holds another JSON type.
100     */
101    public List<CandidateOutcome> getOutcomes() {
102        return typed("outcomes", listOf(CandidateOutcome.READER));
103    }
104
105    /**
106     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
107     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
108     * when the member holds another JSON type.
109     */
110    public Map<String, Extension> getExtensions() {
111        return typed("extensions", mapOf(Extension.READER));
112    }
113
114    /** Collects the members of a new {@code FactCandidate}. */
115    public static final class Builder extends SqllrObject.Builder<FactCandidate, Builder> {
116        private Builder(Map<String, Object> from) {
117            super(from);
118        }
119
120        /** Sets the member {@code ref}; null removes it. */
121        public Builder ref(Long value) {
122            return set("ref", value);
123        }
124
125        /** Sets the member {@code kind}; null removes it. */
126        public Builder kind(String value) {
127            return set("kind", value);
128        }
129
130        /** Sets the member {@code role}; null removes it. */
131        public Builder role(String value) {
132            return set("role", value);
133        }
134
135        /** Sets the member {@code source}; null removes it. */
136        public Builder source(CandidateEnd value) {
137            return set("source", value);
138        }
139
140        /** Sets the member {@code target}; null removes it. */
141        public Builder target(CandidateEnd value) {
142            return set("target", value);
143        }
144
145        /** Sets the member {@code outcomes}; null removes it. */
146        public Builder outcomes(List<CandidateOutcome> value) {
147            return set("outcomes", value);
148        }
149
150        /** Sets the member {@code extensions}; null removes it. */
151        public Builder extensions(Map<String, Extension> value) {
152            return set("extensions", value);
153        }
154
155        @Override
156        public FactCandidate build() {
157            return new FactCandidate(frozenMembers());
158        }
159    }
160}