001package gudusoft.gsqlparser.lineage2.api; 002 003/** 004 * Per-unit analysis configuration for {@link LineageAnalyzer}. 005 * 006 * <p>Carries the identity-layer workspace id, the endpoint-qualification 007 * defaults (D-15 — consumed by the BindingGate story), and the 008 * {@code artifactLocator} bound to every location in the produced document. 009 * All values are optional; unset strings default to the empty string, 010 * matching rev-3 identity normalization ("empty → empty, not NULL"). 011 * 012 * <p>Immutable; construct via {@link #builder()}. 013 * 014 * <p>Internal API: not part of the public gsqlparser surface. 015 */ 016public final class LineageConfig { 017 018 private final String workspaceId; 019 private final String defaultDatabase; 020 private final String defaultSchema; 021 private final String artifactLocator; 022 023 private LineageConfig(Builder b) { 024 this.workspaceId = b.workspaceId; 025 this.defaultDatabase = b.defaultDatabase; 026 this.defaultSchema = b.defaultSchema; 027 this.artifactLocator = b.artifactLocator; 028 } 029 030 public static Builder builder() { 031 return new Builder(); 032 } 033 034 /** A default configuration (all fields empty). */ 035 public static LineageConfig defaults() { 036 return builder().build(); 037 } 038 039 /** Identity-layer workspace id (rev 3); empty when not configured. */ 040 public String getWorkspaceId() { 041 return workspaceId; 042 } 043 044 /** Default database for endpoint qualification (D-15); empty when unset. */ 045 public String getDefaultDatabase() { 046 return defaultDatabase; 047 } 048 049 /** Default schema for endpoint qualification (D-15); empty when unset. */ 050 public String getDefaultSchema() { 051 return defaultSchema; 052 } 053 054 /** 055 * Unit locator bound to the document and every {@code sourceLocation}. 056 * Empty when unset; the {@code File} overload of 057 * {@link LineageAnalyzer#analyze} substitutes the file's base name. 058 */ 059 public String getArtifactLocator() { 060 return artifactLocator; 061 } 062 063 public static final class Builder { 064 private String workspaceId = ""; 065 private String defaultDatabase = ""; 066 private String defaultSchema = ""; 067 private String artifactLocator = ""; 068 069 private Builder() {} 070 071 public Builder workspaceId(String workspaceId) { 072 this.workspaceId = nonNull(workspaceId); 073 return this; 074 } 075 076 public Builder defaultDatabase(String defaultDatabase) { 077 this.defaultDatabase = nonNull(defaultDatabase); 078 return this; 079 } 080 081 public Builder defaultSchema(String defaultSchema) { 082 this.defaultSchema = nonNull(defaultSchema); 083 return this; 084 } 085 086 public Builder artifactLocator(String artifactLocator) { 087 this.artifactLocator = nonNull(artifactLocator); 088 return this; 089 } 090 091 private static String nonNull(String s) { 092 return (s == null) ? "" : s; 093 } 094 095 public LineageConfig build() { 096 return new LineageConfig(this); 097 } 098 } 099}