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 digest of a source unit in one domain: a SHA-256 value, or a keyed token where an unkeyed
010 * digest of the raw bytes could reveal a secret (Section 7.8). Generated from the schema definition
011 * Digest by scripts/sqllr/gen_type_model.py; do not edit.
012 *
013 * @since 4.2.17
014 */
015public final class Digest extends SqllrObject {
016
017    /** The members the schema defines, in schema order. */
018    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("domain", "value", "tokenDomain"));
019
020    /** The members the schema requires. */
021    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("domain", "value"));
022
023    /** Reads a JSON object as a {@code Digest}. */
024    public static final Reader<Digest> READER = new Reader<Digest>() {
025        @Override
026        public Digest read(Object json) {
027            return fromJson(json);
028        }
029    };
030
031    private Digest(Map<String, Object> members) {
032        super(members);
033    }
034
035    /** A {@code Digest} with the members of a JSON object, all kept. */
036    public static Digest fromJson(Object json) {
037        return new Digest(members(json, "Digest"));
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 domain}. A digest domain. Registry group 'digestDomains' (Sections 4.5, 7.8
051     * and 14.3, item 6). Null when absent; throws IllegalStateException when the member holds
052     * another JSON type.
053     */
054    public String getDomain() {
055        return string("domain");
056    }
057
058    /**
059     * The member {@code value}. Null when absent; throws IllegalStateException when the member
060     * holds another JSON type.
061     */
062    public String getValue() {
063        return string("value");
064    }
065
066    /**
067     * The member {@code tokenDomain}. The comparison domain of a KEYED_TOKEN. Null when absent;
068     * throws IllegalStateException when the member holds another JSON type.
069     */
070    public String getTokenDomain() {
071        return string("tokenDomain");
072    }
073
074    /** Collects the members of a new {@code Digest}. */
075    public static final class Builder extends SqllrObject.Builder<Digest, Builder> {
076        private Builder(Map<String, Object> from) {
077            super(from);
078        }
079
080        /** Sets the member {@code domain}; null removes it. */
081        public Builder domain(String value) {
082            return set("domain", value);
083        }
084
085        /** Sets the member {@code value}; null removes it. */
086        public Builder value(String value) {
087            return set("value", value);
088        }
089
090        /** Sets the member {@code tokenDomain}; null removes it. */
091        public Builder tokenDomain(String value) {
092            return set("tokenDomain", value);
093        }
094
095        @Override
096        public Digest build() {
097            return new Digest(frozenMembers());
098        }
099    }
100}