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 metadata supplied to one analysis (Section 6.2). Generated from the schema definition
010 * Metadata by scripts/sqllr/gen_type_model.py; do not edit.
011 *
012 * @since 4.2.17
013 */
014public final class Metadata extends SqllrObject {
015
016    /** The members the schema defines, in schema order. */
017    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("status", "digest", "artifacts", "extensions"));
018
019    /** The members the schema requires. */
020    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("status"));
021
022    /** Reads a JSON object as a {@code Metadata}. */
023    public static final Reader<Metadata> READER = new Reader<Metadata>() {
024        @Override
025        public Metadata read(Object json) {
026            return fromJson(json);
027        }
028    };
029
030    private Metadata(Map<String, Object> members) {
031        super(members);
032    }
033
034    /** A {@code Metadata} with the members of a JSON object, all kept. */
035    public static Metadata fromJson(Object json) {
036        return new Metadata(members(json, "Metadata"));
037    }
038
039    public static Builder builder() {
040        return new Builder(null);
041    }
042
043    /** A builder holding every member of this object. */
044    public Builder toBuilder() {
045        return new Builder(toJson());
046    }
047
048    /**
049     * The member {@code status}. The metadata status of the analysis. Registry group
050     * 'metadataStatus' (Section 6.2). Null when absent; throws IllegalStateException when the
051     * member holds another JSON type.
052     */
053    public String getStatus() {
054        return string("status");
055    }
056
057    /**
058     * The member {@code digest}. MetadataDigestV1 of artifacts (algorithms/identity-v1.md, Section
059     * 5.11): an input of every analysis context of the analysis; required unless the status is
060     * NONE. A SHA-256 digest: 64 lowercase hexadecimal characters. Null when absent; throws
061     * IllegalStateException when the member holds another JSON type.
062     */
063    public String getDigest() {
064        return string("digest");
065    }
066
067    /**
068     * The member {@code artifacts}. Every metadata artifact supplied to the analysis, consulted or
069     * not: its format id and the SHA-256 of its bytes. Required unless the status is NONE. Null
070     * when absent; throws IllegalStateException when the member holds another JSON type.
071     */
072    public List<MetadataArtifact> getArtifacts() {
073        return typed("artifacts", listOf(MetadataArtifact.READER));
074    }
075
076    /**
077     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
078     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
079     * when the member holds another JSON type.
080     */
081    public Map<String, Extension> getExtensions() {
082        return typed("extensions", mapOf(Extension.READER));
083    }
084
085    /** Collects the members of a new {@code Metadata}. */
086    public static final class Builder extends SqllrObject.Builder<Metadata, Builder> {
087        private Builder(Map<String, Object> from) {
088            super(from);
089        }
090
091        /** Sets the member {@code status}; null removes it. */
092        public Builder status(String value) {
093            return set("status", value);
094        }
095
096        /** Sets the member {@code digest}; null removes it. */
097        public Builder digest(String value) {
098            return set("digest", value);
099        }
100
101        /** Sets the member {@code artifacts}; null removes it. */
102        public Builder artifacts(List<MetadataArtifact> value) {
103            return set("artifacts", value);
104        }
105
106        /** Sets the member {@code extensions}; null removes it. */
107        public Builder extensions(Map<String, Extension> value) {
108            return set("extensions", value);
109        }
110
111        @Override
112        public Metadata build() {
113            return new Metadata(frozenMembers());
114        }
115    }
116}