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 * Extension data of one namespace (Section 14.3, item 7). An unknown optional extension is
010 * preserved unchanged; an unknown required extension makes the operations that depend on it fail.
011 * Generated from the schema definition Extension by scripts/sqllr/gen_type_model.py; do not edit.
012 *
013 * @since 4.2.17
014 */
015public final class Extension extends SqllrObject {
016
017    /** The members the schema defines, in schema order. */
018    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("version", "required", "data"));
019
020    /** The members the schema requires. */
021    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("version", "required", "data"));
022
023    /** Reads a JSON object as a {@code Extension}. */
024    public static final Reader<Extension> READER = new Reader<Extension>() {
025        @Override
026        public Extension read(Object json) {
027            return fromJson(json);
028        }
029    };
030
031    private Extension(Map<String, Object> members) {
032        super(members);
033    }
034
035    /** A {@code Extension} with the members of a JSON object, all kept. */
036    public static Extension fromJson(Object json) {
037        return new Extension(members(json, "Extension"));
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 version}. Null when absent; throws IllegalStateException when the member
051     * holds another JSON type.
052     */
053    public String getVersion() {
054        return string("version");
055    }
056
057    /**
058     * The member {@code required}. Null when absent; throws IllegalStateException when the member
059     * holds another JSON type.
060     */
061    public Boolean getRequired() {
062        return bool("required");
063    }
064
065    /**
066     * The member {@code data}. Extension content; any JSON value without floating-point numbers.
067     * Null when absent, {@link SqllrObject#JSON_NULL} when present with JSON null.
068     */
069    public Object getData() {
070        return anyMember("data");
071    }
072
073    /** Collects the members of a new {@code Extension}. */
074    public static final class Builder extends SqllrObject.Builder<Extension, Builder> {
075        private Builder(Map<String, Object> from) {
076            super(from);
077        }
078
079        /** Sets the member {@code version}; null removes it. */
080        public Builder version(String value) {
081            return set("version", value);
082        }
083
084        /** Sets the member {@code required}; null removes it. */
085        public Builder required(Boolean value) {
086            return set("required", value);
087        }
088
089        /**
090         * Sets the member {@code data}; null removes it, {@link SqllrObject#JSON_NULL} sets JSON
091         * null.
092         */
093        public Builder data(Object value) {
094            return set("data", value);
095        }
096
097        @Override
098        public Extension build() {
099            return new Extension(frozenMembers());
100        }
101    }
102}