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 name-resolution and lifetime scope. A binding names the scope in which its reference was 010 * resolved; a local endpoint names the scope that bounds its lifetime (Sections 4.2 and 9.1). 011 * Generated from the schema definition Scope by scripts/sqllr/gen_type_model.py; do not edit. 012 * 013 * @since 4.2.17 014 */ 015public final class Scope 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", "parentRef", "statementRef", "sourceUnitRef", "path", "extensions")); 019 020 /** The members the schema requires. */ 021 public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "kind")); 022 023 /** Reads a JSON object as a {@code Scope}. */ 024 public static final Reader<Scope> READER = new Reader<Scope>() { 025 @Override 026 public Scope read(Object json) { 027 return fromJson(json); 028 } 029 }; 030 031 private Scope(Map<String, Object> members) { 032 super(members); 033 } 034 035 /** A {@code Scope} with the members of a JSON object, all kept. */ 036 public static Scope fromJson(Object json) { 037 return new Scope(members(json, "Scope")); 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}. The kind of a scope. Registry group 'scopeKinds' (Sections 4.2 and 061 * 9.1). Null when 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 parentRef}. The enclosing scope. A document-local reference: an integer 069 * that is unique across the whole document (one reference space for every object that carries a 070 * ref). Local references are assigned after merging and have no meaning outside the document 071 * (Sections 6.1 and 13). Null when absent; throws IllegalStateException when the member holds 072 * another JSON type. 073 */ 074 public Long getParentRef() { 075 return integer("parentRef"); 076 } 077 078 /** 079 * The member {@code statementRef}. A document-local reference: an integer that is unique across 080 * the whole document (one reference space for every object that carries a ref). Local 081 * references are assigned after merging and have no meaning outside the document (Sections 6.1 082 * and 13). Null when absent; throws IllegalStateException when the member holds another JSON 083 * type. 084 */ 085 public Long getStatementRef() { 086 return integer("statementRef"); 087 } 088 089 /** 090 * The member {@code sourceUnitRef}. A document-local reference: an integer that is unique 091 * across the whole document (one reference space for every object that carries a ref). Local 092 * references are assigned after merging and have no meaning outside the document (Sections 6.1 093 * and 13). Null when absent; throws IllegalStateException when the member holds another JSON 094 * type. 095 */ 096 public Long getSourceUnitRef() { 097 return integer("sourceUnitRef"); 098 } 099 100 /** 101 * The member {@code path}. The semantic path of the query block within its statement. A 102 * semantic path. Under the path profile sqllr-path-1 it is a '/'-joined list of steps 103 * CODE[index] (registry group pathStepCodes) that follows algorithms/path-v1.md (semantic 104 * stage: SEMANTIC_PATH_PROFILE_VIOLATION); under another declared profile it is opaque and 105 * comparable only within (producer, path profile). Null when absent; throws 106 * IllegalStateException when the member holds another JSON type. 107 */ 108 public String getPath() { 109 return string("path"); 110 } 111 112 /** 113 * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry 114 * it; it never takes part in a core identity. Null when absent; throws IllegalStateException 115 * when the member holds another JSON type. 116 */ 117 public Map<String, Extension> getExtensions() { 118 return typed("extensions", mapOf(Extension.READER)); 119 } 120 121 /** Collects the members of a new {@code Scope}. */ 122 public static final class Builder extends SqllrObject.Builder<Scope, Builder> { 123 private Builder(Map<String, Object> from) { 124 super(from); 125 } 126 127 /** Sets the member {@code ref}; null removes it. */ 128 public Builder ref(Long value) { 129 return set("ref", value); 130 } 131 132 /** Sets the member {@code kind}; null removes it. */ 133 public Builder kind(String value) { 134 return set("kind", value); 135 } 136 137 /** Sets the member {@code parentRef}; null removes it. */ 138 public Builder parentRef(Long value) { 139 return set("parentRef", value); 140 } 141 142 /** Sets the member {@code statementRef}; null removes it. */ 143 public Builder statementRef(Long value) { 144 return set("statementRef", value); 145 } 146 147 /** Sets the member {@code sourceUnitRef}; null removes it. */ 148 public Builder sourceUnitRef(Long value) { 149 return set("sourceUnitRef", value); 150 } 151 152 /** Sets the member {@code path}; null removes it. */ 153 public Builder path(String value) { 154 return set("path", value); 155 } 156 157 /** Sets the member {@code extensions}; null removes it. */ 158 public Builder extensions(Map<String, Extension> value) { 159 return set("extensions", value); 160 } 161 162 @Override 163 public Scope build() { 164 return new Scope(frozenMembers()); 165 } 166 } 167}