001package gudusoft.gsqlparser.dlineage.symbol;
002
003import gudusoft.gsqlparser.dlineage.dataflow.model.Table;
004
005import java.util.LinkedHashMap;
006
007/**
008 * The lineage model's local symbols (variables, cursors, declared types, trigger correlation names, table variables)
009 * by {@link LocalSymbolKey}: a namespace of its own, apart from the physical tables, in declaration order. Re-binding a
010 * key replaces its value, as the legacy shared map did.
011 */
012public final class LocalSymbolRegistry {
013
014    private final LinkedHashMap<LocalSymbolKey, Table> symbols = new LinkedHashMap<LocalSymbolKey, Table>();
015
016    public void put(LocalSymbolKey key, Table symbol) {
017        if (key != null && symbol != null) {
018            symbols.put(key, symbol);
019        }
020    }
021
022    public Table get(LocalSymbolKey key) {
023        return key == null ? null : symbols.get(key);
024    }
025
026    public boolean contains(LocalSymbolKey key) {
027        return key != null && symbols.containsKey(key);
028    }
029
030    public int size() {
031        return symbols.size();
032    }
033
034    public void clear() {
035        symbols.clear();
036    }
037}