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 * One write of a target field by one statement, with all of its inputs (Section 4.4). Zero inputs
010 * are valid only with COMPLETE plus an upstreamDisposition and a reason; otherwise the write is
011 * UNKNOWN (semantic stage: SEMANTIC_ZERO_UPSTREAM_INVALID). Generated from the schema definition
012 * TargetFieldOccurrence by scripts/sqllr/gen_type_model.py; do not edit.
013 *
014 * @since 4.2.17
015 */
016public final class TargetFieldOccurrence extends SqllrObject {
017
018    /** The members the schema defines, in schema order. */
019    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "statementRef", "targetRef", "assignmentOrdinal", "inputs", "upstreamCompleteness", "upstreamDisposition", "upstreamDispositionReason", "diagnosticRefs", "extensions"));
020
021    /** The members the schema requires. */
022    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "statementRef", "targetRef", "assignmentOrdinal", "inputs", "upstreamCompleteness"));
023
024    /** Reads a JSON object as a {@code TargetFieldOccurrence}. */
025    public static final Reader<TargetFieldOccurrence> READER = new Reader<TargetFieldOccurrence>() {
026        @Override
027        public TargetFieldOccurrence read(Object json) {
028            return fromJson(json);
029        }
030    };
031
032    private TargetFieldOccurrence(Map<String, Object> members) {
033        super(members);
034    }
035
036    /** A {@code TargetFieldOccurrence} with the members of a JSON object, all kept. */
037    public static TargetFieldOccurrence fromJson(Object json) {
038        return new TargetFieldOccurrence(members(json, "TargetFieldOccurrence"));
039    }
040
041    public static Builder builder() {
042        return new Builder(null);
043    }
044
045    /** A builder holding every member of this object. */
046    public Builder toBuilder() {
047        return new Builder(toJson());
048    }
049
050    /**
051     * The member {@code ref}. A document-local reference: an integer that is unique across the
052     * whole document (one reference space for every object that carries a ref). Local references
053     * are assigned after merging and have no meaning outside the document (Sections 6.1 and 13).
054     * Null when absent; throws IllegalStateException when the member holds another JSON type.
055     */
056    public Long getRef() {
057        return integer("ref");
058    }
059
060    /**
061     * The member {@code statementRef}. A document-local reference: an integer that is unique across
062     * the whole document (one reference space for every object that carries a ref). Local
063     * references are assigned after merging and have no meaning outside the document (Sections 6.1
064     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
065     * type.
066     */
067    public Long getStatementRef() {
068        return integer("statementRef");
069    }
070
071    /**
072     * The member {@code targetRef}. A document-local reference: an integer that is unique across
073     * the whole document (one reference space for every object that carries a ref). Local
074     * references are assigned after merging and have no meaning outside the document (Sections 6.1
075     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
076     * type.
077     */
078    public Long getTargetRef() {
079        return integer("targetRef");
080    }
081
082    /**
083     * The member {@code assignmentOrdinal}. 0-based position of the assignment within the
084     * statement. A 0-based ordinal. Null when absent; throws IllegalStateException when the member
085     * holds another JSON type.
086     */
087    public Long getAssignmentOrdinal() {
088        return integer("assignmentOrdinal");
089    }
090
091    /**
092     * The member {@code inputs}. Null when absent; throws IllegalStateException when the member
093     * holds another JSON type.
094     */
095    public List<Input> getInputs() {
096        return typed("inputs", listOf(Input.READER));
097    }
098
099    /**
100     * The member {@code upstreamCompleteness}. Upstream completeness of one write. Registry group
101     * 'upstreamCompleteness' (Section 4.4). Null when absent; throws IllegalStateException when the
102     * member holds another JSON type.
103     */
104    public String getUpstreamCompleteness() {
105        return string("upstreamCompleteness");
106    }
107
108    /**
109     * The member {@code upstreamDisposition}. Why a write with COMPLETE upstream has no inputs.
110     * Registry group 'upstreamDisposition' (Section 4.4). Null when absent; throws
111     * IllegalStateException when the member holds another JSON type.
112     */
113    public String getUpstreamDisposition() {
114        return string("upstreamDisposition");
115    }
116
117    /**
118     * The member {@code upstreamDispositionReason}. Why the write has no value input. Null when
119     * absent; throws IllegalStateException when the member holds another JSON type.
120     */
121    public String getUpstreamDispositionReason() {
122        return string("upstreamDispositionReason");
123    }
124
125    /**
126     * The member {@code diagnosticRefs}. The diagnostics that lowered the completeness of this
127     * write. A set of local references. Null when absent; throws IllegalStateException when the
128     * member holds another JSON type.
129     */
130    public List<Long> getDiagnosticRefs() {
131        return typed("diagnosticRefs", listOf(INTEGER));
132    }
133
134    /**
135     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
136     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
137     * when the member holds another JSON type.
138     */
139    public Map<String, Extension> getExtensions() {
140        return typed("extensions", mapOf(Extension.READER));
141    }
142
143    /** Collects the members of a new {@code TargetFieldOccurrence}. */
144    public static final class Builder extends SqllrObject.Builder<TargetFieldOccurrence, Builder> {
145        private Builder(Map<String, Object> from) {
146            super(from);
147        }
148
149        /** Sets the member {@code ref}; null removes it. */
150        public Builder ref(Long value) {
151            return set("ref", value);
152        }
153
154        /** Sets the member {@code statementRef}; null removes it. */
155        public Builder statementRef(Long value) {
156            return set("statementRef", value);
157        }
158
159        /** Sets the member {@code targetRef}; null removes it. */
160        public Builder targetRef(Long value) {
161            return set("targetRef", value);
162        }
163
164        /** Sets the member {@code assignmentOrdinal}; null removes it. */
165        public Builder assignmentOrdinal(Long value) {
166            return set("assignmentOrdinal", value);
167        }
168
169        /** Sets the member {@code inputs}; null removes it. */
170        public Builder inputs(List<Input> value) {
171            return set("inputs", value);
172        }
173
174        /** Sets the member {@code upstreamCompleteness}; null removes it. */
175        public Builder upstreamCompleteness(String value) {
176            return set("upstreamCompleteness", value);
177        }
178
179        /** Sets the member {@code upstreamDisposition}; null removes it. */
180        public Builder upstreamDisposition(String value) {
181            return set("upstreamDisposition", value);
182        }
183
184        /** Sets the member {@code upstreamDispositionReason}; null removes it. */
185        public Builder upstreamDispositionReason(String value) {
186            return set("upstreamDispositionReason", value);
187        }
188
189        /** Sets the member {@code diagnosticRefs}; null removes it. */
190        public Builder diagnosticRefs(List<Long> value) {
191            return set("diagnosticRefs", value);
192        }
193
194        /** Sets the member {@code extensions}; null removes it. */
195        public Builder extensions(Map<String, Extension> value) {
196            return set("extensions", value);
197        }
198
199        @Override
200        public TargetFieldOccurrence build() {
201            return new TargetFieldOccurrence(frozenMembers());
202        }
203    }
204}