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 ExplainGraph of the document (Sections 3.4, 3.5 and 7.7). Module explain; folded into the
010 * Fact layer by FOLD-V1 (algorithms/fold-v1.md). Nodes, micro-edges, candidate sets and support
011 * paths share the document's reference space. A micro-edge end is an Endpoint of the document (a
012 * kept node), an ExplainGraph node (a folded or TERMINAL node), or, only as the source of an
013 * UNRESOLVED reference, a candidate set of this graph. Generated from the schema definition
014 * ExplainGraph by scripts/sqllr/gen_type_model.py; do not edit.
015 *
016 * @since 4.2.17
017 */
018public final class ExplainGraph extends SqllrObject {
019
020    /** The members the schema defines, in schema order. */
021    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("completeness", "statementCompleteness", "nodes", "microEdges", "candidateSets", "supportPaths", "extensions"));
022
023    /** The members the schema requires. */
024    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("completeness", "nodes", "microEdges", "supportPaths"));
025
026    /** Reads a JSON object as a {@code ExplainGraph}. */
027    public static final Reader<ExplainGraph> READER = new Reader<ExplainGraph>() {
028        @Override
029        public ExplainGraph read(Object json) {
030            return fromJson(json);
031        }
032    };
033
034    private ExplainGraph(Map<String, Object> members) {
035        super(members);
036    }
037
038    /** A {@code ExplainGraph} with the members of a JSON object, all kept. */
039    public static ExplainGraph fromJson(Object json) {
040        return new ExplainGraph(members(json, "ExplainGraph"));
041    }
042
043    public static Builder builder() {
044        return new Builder(null);
045    }
046
047    /** A builder holding every member of this object. */
048    public Builder toBuilder() {
049        return new Builder(toJson());
050    }
051
052    /**
053     * The member {@code completeness}. The completeness of the graph of every statement that
054     * statementCompleteness does not list. COMPLETE: folding yields every Fact Occurrence and
055     * FactCandidate of those statements. Completeness declared by an ExplainGraph. Registry group
056     * 'explainGraphCompleteness' (Section 3.5). Null when absent; throws IllegalStateException when
057     * the member holds another JSON type.
058     */
059    public String getCompleteness() {
060        return string("completeness");
061    }
062
063    /**
064     * The member {@code statementCompleteness}. Completeness of the graph of individual statements,
065     * where it differs from completeness. Null when absent; throws IllegalStateException when the
066     * member holds another JSON type.
067     */
068    public List<ExplainStatementCompleteness> getStatementCompleteness() {
069        return typed("statementCompleteness", listOf(ExplainStatementCompleteness.READER));
070    }
071
072    /**
073     * The member {@code nodes}. Null when absent; throws IllegalStateException when the member
074     * holds another JSON type.
075     */
076    public List<ExplainNode> getNodes() {
077        return typed("nodes", listOf(ExplainNode.READER));
078    }
079
080    /**
081     * The member {@code microEdges}. Null when absent; throws IllegalStateException when the member
082     * holds another JSON type.
083     */
084    public List<MicroEdge> getMicroEdges() {
085        return typed("microEdges", listOf(MicroEdge.READER));
086    }
087
088    /**
089     * The member {@code candidateSets}. The candidate sets of the ambiguous and unresolved
090     * references of the graph (algorithms/fold-v1.md, Section 4.3). Null when absent; throws
091     * IllegalStateException when the member holds another JSON type.
092     */
093    public List<CandidateSet> getCandidateSets() {
094        return typed("candidateSets", listOf(CandidateSet.READER));
095    }
096
097    /**
098     * The member {@code supportPaths}. Null when absent; throws IllegalStateException when the
099     * member holds another JSON type.
100     */
101    public List<SupportPath> getSupportPaths() {
102        return typed("supportPaths", listOf(SupportPath.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 ExplainGraph}. */
115    public static final class Builder extends SqllrObject.Builder<ExplainGraph, Builder> {
116        private Builder(Map<String, Object> from) {
117            super(from);
118        }
119
120        /** Sets the member {@code completeness}; null removes it. */
121        public Builder completeness(String value) {
122            return set("completeness", value);
123        }
124
125        /** Sets the member {@code statementCompleteness}; null removes it. */
126        public Builder statementCompleteness(List<ExplainStatementCompleteness> value) {
127            return set("statementCompleteness", value);
128        }
129
130        /** Sets the member {@code nodes}; null removes it. */
131        public Builder nodes(List<ExplainNode> value) {
132            return set("nodes", value);
133        }
134
135        /** Sets the member {@code microEdges}; null removes it. */
136        public Builder microEdges(List<MicroEdge> value) {
137            return set("microEdges", value);
138        }
139
140        /** Sets the member {@code candidateSets}; null removes it. */
141        public Builder candidateSets(List<CandidateSet> value) {
142            return set("candidateSets", value);
143        }
144
145        /** Sets the member {@code supportPaths}; null removes it. */
146        public Builder supportPaths(List<SupportPath> value) {
147            return set("supportPaths", 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 ExplainGraph build() {
157            return new ExplainGraph(frozenMembers());
158        }
159    }
160}