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 segment of an endpoint name (Sections 6.3 and 9.1). A NAMED segment carries text; a
010 * PRODUCER_DEFAULT segment is exactly {role, kind} and never equals a real name. Generated from the
011 * schema definition NameSegment by scripts/sqllr/gen_type_model.py; do not edit.
012 *
013 * @since 4.2.17
014 */
015public final class NameSegment extends SqllrObject {
016
017    /** The members the schema defines, in schema order. */
018    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("role", "kind", "text", "inputForm", "quoteState", "provenance", "canonicalKey", "keyUnavailable"));
019
020    /** The members the schema requires. */
021    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("role", "kind"));
022
023    /** Reads a JSON object as a {@code NameSegment}. */
024    public static final Reader<NameSegment> READER = new Reader<NameSegment>() {
025        @Override
026        public NameSegment read(Object json) {
027            return fromJson(json);
028        }
029    };
030
031    private NameSegment(Map<String, Object> members) {
032        super(members);
033    }
034
035    /** A {@code NameSegment} with the members of a JSON object, all kept. */
036    public static NameSegment fromJson(Object json) {
037        return new NameSegment(members(json, "NameSegment"));
038    }
039
040    public static Builder builder() {
041        return new Builder(null);
042    }
043
044    /** A builder holding every member of this object. */
045    public Builder toBuilder() {
046        return new Builder(toJson());
047    }
048
049    /**
050     * The member {@code role}. The role of a name segment. Registry group 'segmentRoles' (Sections
051     * 6.3 and 9.1). Null when absent; throws IllegalStateException when the member holds another
052     * JSON type.
053     */
054    public String getRole() {
055        return string("role");
056    }
057
058    /**
059     * The member {@code kind}. The kind of a name segment. Registry group 'nameSegmentKinds'
060     * (Section 9.1). Null when absent; throws IllegalStateException when the member holds another
061     * JSON type.
062     */
063    public String getKind() {
064        return string("kind");
065    }
066
067    /**
068     * The member {@code text}. The segment text: as written (SQL_LEXICAL, without delimiters), as
069     * stored (CATALOG_STORED), or byte-for-byte for AUTHORITY and LOCATION. Null when absent;
070     * throws IllegalStateException when the member holds another JSON type.
071     */
072    public String getText() {
073        return string("text");
074    }
075
076    /**
077     * The member {@code inputForm}. The input form of a name segment. Registry group
078     * 'nameSegmentInputForms' (Section 6.3). Null when absent; throws IllegalStateException when
079     * the member holds another JSON type.
080     */
081    public String getInputForm() {
082        return string("inputForm");
083    }
084
085    /**
086     * The member {@code quoteState}. The quote state of a SQL_LEXICAL name segment. Registry group
087     * 'quoteStates' (Section 6.3). Null when absent; throws IllegalStateException when the member
088     * holds another JSON type.
089     */
090    public String getQuoteState() {
091        return string("quoteState");
092    }
093
094    /**
095     * The member {@code provenance}. Where the text of a NAMED segment came from. Registry group
096     * 'segmentProvenance' (Sections 6.3 and 9.1). Null when absent; throws IllegalStateException
097     * when the member holds another JSON type.
098     */
099    public String getProvenance() {
100        return string("provenance");
101    }
102
103    /**
104     * The member {@code canonicalKey}. The canonical segment key minted by CanonicalSegmentKeyV1
105     * (identifier-rules/FORMAT.md, Section 9) from the dialect rule set of the dependency snapshot,
106     * the object type of registry/qualification-profiles.json (segmentObjectTypes), text, inputForm
107     * and quoteState. EndpointIdV1 frames it; recomputed at the identity stage. Absent for
108     * AUTHORITY and LOCATION segments, whose text is used byte for byte. Null when absent; throws
109     * IllegalStateException when the member holds another JSON type.
110     */
111    public String getCanonicalKey() {
112        return string("canonicalKey");
113    }
114
115    /**
116     * The member {@code keyUnavailable}. Why no canonical key can be minted; excludes canonicalKey.
117     * Why a canonical segment key cannot be minted. Registry group 'keyUnavailableReasons'
118     * (Sections 6.3 and 10.6). Null when absent; throws IllegalStateException when the member holds
119     * another JSON type.
120     */
121    public String getKeyUnavailable() {
122        return string("keyUnavailable");
123    }
124
125    /** Collects the members of a new {@code NameSegment}. */
126    public static final class Builder extends SqllrObject.Builder<NameSegment, Builder> {
127        private Builder(Map<String, Object> from) {
128            super(from);
129        }
130
131        /** Sets the member {@code role}; null removes it. */
132        public Builder role(String value) {
133            return set("role", value);
134        }
135
136        /** Sets the member {@code kind}; null removes it. */
137        public Builder kind(String value) {
138            return set("kind", value);
139        }
140
141        /** Sets the member {@code text}; null removes it. */
142        public Builder text(String value) {
143            return set("text", value);
144        }
145
146        /** Sets the member {@code inputForm}; null removes it. */
147        public Builder inputForm(String value) {
148            return set("inputForm", value);
149        }
150
151        /** Sets the member {@code quoteState}; null removes it. */
152        public Builder quoteState(String value) {
153            return set("quoteState", value);
154        }
155
156        /** Sets the member {@code provenance}; null removes it. */
157        public Builder provenance(String value) {
158            return set("provenance", value);
159        }
160
161        /** Sets the member {@code canonicalKey}; null removes it. */
162        public Builder canonicalKey(String value) {
163            return set("canonicalKey", value);
164        }
165
166        /** Sets the member {@code keyUnavailable}; null removes it. */
167        public Builder keyUnavailable(String value) {
168            return set("keyUnavailable", value);
169        }
170
171        @Override
172        public NameSegment build() {
173            return new NameSegment(frozenMembers());
174        }
175    }
176}