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 * An atomic proposition from one source endpoint to one target endpoint (Sections 3.1 to 3.3). Its
010 * identity excludes statement, location, process, evidence, status and display text. Generated from
011 * the schema definition Fact by scripts/sqllr/gen_type_model.py; do not edit.
012 *
013 * @since 4.2.17
014 */
015public final class Fact extends SqllrObject {
016
017    /** The members the schema defines, in schema order. */
018    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "kind", "role", "sourceRef", "targetRef", "id", "numericKey", "datasetDependency", "extensions"));
019
020    /** The members the schema requires. */
021    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "kind", "sourceRef", "targetRef"));
022
023    /** Reads a JSON object as a {@code Fact}. */
024    public static final Reader<Fact> READER = new Reader<Fact>() {
025        @Override
026        public Fact read(Object json) {
027            return fromJson(json);
028        }
029    };
030
031    private Fact(Map<String, Object> members) {
032        super(members);
033    }
034
035    /** A {@code Fact} with the members of a JSON object, all kept. */
036    public static Fact fromJson(Object json) {
037        return new Fact(members(json, "Fact"));
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 ref}. A document-local reference: an integer that is unique across the
051     * whole document (one reference space for every object that carries a ref). Local references
052     * are assigned after merging and have no meaning outside the document (Sections 6.1 and 13).
053     * Null when absent; throws IllegalStateException when the member holds another JSON type.
054     */
055    public Long getRef() {
056        return integer("ref");
057    }
058
059    /**
060     * The member {@code kind}. A Fact kind. Registry group 'factKinds' (Section 3.3). Null when
061     * absent; throws IllegalStateException when the member holds another JSON type.
062     */
063    public String getKind() {
064        return string("kind");
065    }
066
067    /**
068     * The member {@code role}. The role of a ROW Fact. Registry group 'rowRoles' (Section 3.3).
069     * Null when absent; throws IllegalStateException when the member holds another JSON type.
070     */
071    public String getRole() {
072        return string("role");
073    }
074
075    /**
076     * The member {@code sourceRef}. A document-local reference: an integer that is unique across
077     * the whole document (one reference space for every object that carries a ref). Local
078     * references are assigned after merging and have no meaning outside the document (Sections 6.1
079     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
080     * type.
081     */
082    public Long getSourceRef() {
083        return integer("sourceRef");
084    }
085
086    /**
087     * The member {@code targetRef}. A document-local reference: an integer that is unique across
088     * the whole document (one reference space for every object that carries a ref). Local
089     * references are assigned after merging and have no meaning outside the document (Sections 6.1
090     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
091     * type.
092     */
093    public Long getTargetRef() {
094        return integer("targetRef");
095    }
096
097    /**
098     * The member {@code id}. Present when both endpoints have a portable identity (identity stage:
099     * ID_MISSING / ID_UNEXPECTED). An id computed by FactIdV1: 'fact1-' followed by 64 lowercase
100     * hexadecimal characters of a SHA-256 digest (algorithms/identity-v1.md). Null when absent;
101     * throws IllegalStateException when the member holds another JSON type.
102     */
103    public String getId() {
104        return string("id");
105    }
106
107    /**
108     * The member {@code numericKey}. A 128-bit numeric key (NumericKeyV1): the first 16 bytes of
109     * the SHA-256 digest of an id, big-endian, as 32 lowercase hexadecimal characters, which are
110     * the first 32 hexadecimal characters of the id (Section 11.5; algorithms/identity-v1.md,
111     * Section 5.10). Consumers keep the full id as the authority. Null when absent; throws
112     * IllegalStateException when the member holds another JSON type.
113     */
114    public String getNumericKey() {
115        return string("numericKey");
116    }
117
118    /**
119     * The member {@code datasetDependency}. Null when absent; throws IllegalStateException when the
120     * member holds another JSON type.
121     */
122    public DatasetDependency getDatasetDependency() {
123        return typed("datasetDependency", DatasetDependency.READER);
124    }
125
126    /**
127     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
128     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
129     * when the member holds another JSON type.
130     */
131    public Map<String, Extension> getExtensions() {
132        return typed("extensions", mapOf(Extension.READER));
133    }
134
135    /** Collects the members of a new {@code Fact}. */
136    public static final class Builder extends SqllrObject.Builder<Fact, Builder> {
137        private Builder(Map<String, Object> from) {
138            super(from);
139        }
140
141        /** Sets the member {@code ref}; null removes it. */
142        public Builder ref(Long value) {
143            return set("ref", value);
144        }
145
146        /** Sets the member {@code kind}; null removes it. */
147        public Builder kind(String value) {
148            return set("kind", value);
149        }
150
151        /** Sets the member {@code role}; null removes it. */
152        public Builder role(String value) {
153            return set("role", value);
154        }
155
156        /** Sets the member {@code sourceRef}; null removes it. */
157        public Builder sourceRef(Long value) {
158            return set("sourceRef", value);
159        }
160
161        /** Sets the member {@code targetRef}; null removes it. */
162        public Builder targetRef(Long value) {
163            return set("targetRef", value);
164        }
165
166        /** Sets the member {@code id}; null removes it. */
167        public Builder id(String value) {
168            return set("id", value);
169        }
170
171        /** Sets the member {@code numericKey}; null removes it. */
172        public Builder numericKey(String value) {
173            return set("numericKey", value);
174        }
175
176        /** Sets the member {@code datasetDependency}; null removes it. */
177        public Builder datasetDependency(DatasetDependency value) {
178            return set("datasetDependency", value);
179        }
180
181        /** Sets the member {@code extensions}; null removes it. */
182        public Builder extensions(Map<String, Extension> value) {
183            return set("extensions", value);
184        }
185
186        @Override
187        public Fact build() {
188            return new Fact(frozenMembers());
189        }
190    }
191}