001package gudusoft.gsqlparser.catalog.input.model; 002 003import gudusoft.gsqlparser.catalog.input.CatalogInputKind; 004 005import java.util.Objects; 006 007/** 008 * Provenance of a {@link UnifiedCatalogModel}: which kind of source produced it, when, and 009 * a free-form name for diagnostic messages. 010 * 011 * <p>Plan §6 / §7.1.</p> 012 */ 013public final class CatalogSourceInfo { 014 015 private final CatalogInputKind kind; 016 private final String name; 017 private final long readMillis; 018 019 private CatalogSourceInfo(Builder b) { 020 if (b.kind == null) { 021 throw new IllegalArgumentException("CatalogSourceInfo.kind is required"); 022 } 023 this.kind = b.kind; 024 this.name = b.name; 025 this.readMillis = b.readMillis; 026 } 027 028 public static Builder builder() { 029 return new Builder(); 030 } 031 032 public CatalogInputKind kind() { 033 return kind; 034 } 035 036 public String name() { 037 return name; 038 } 039 040 public long readMillis() { 041 return readMillis; 042 } 043 044 @Override 045 public boolean equals(Object o) { 046 if (this == o) return true; 047 if (!(o instanceof CatalogSourceInfo)) return false; 048 CatalogSourceInfo that = (CatalogSourceInfo) o; 049 return readMillis == that.readMillis 050 && kind == that.kind 051 && Objects.equals(name, that.name); 052 } 053 054 @Override 055 public int hashCode() { 056 return Objects.hash(kind, name, readMillis); 057 } 058 059 @Override 060 public String toString() { 061 return "CatalogSourceInfo{kind=" + kind + ", name=" + name + ", readMillis=" + readMillis + '}'; 062 } 063 064 public static final class Builder { 065 066 private CatalogInputKind kind; 067 private String name; 068 private long readMillis; 069 070 private Builder() { 071 } 072 073 public Builder kind(CatalogInputKind v) { 074 this.kind = v; 075 return this; 076 } 077 078 public Builder name(String v) { 079 this.name = v; 080 return this; 081 } 082 083 public Builder readMillis(long v) { 084 this.readMillis = v; 085 return this; 086 } 087 088 public CatalogSourceInfo build() { 089 return new CatalogSourceInfo(this); 090 } 091 } 092}