com.virtusa.gto.nyql.db.TranslatorOptions Maven / Gradle / Ivy
package com.virtusa.gto.nyql.db;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @author Isuru Weerarathna
*/
public class TranslatorOptions {
private final Collection keywords;
private final Map tableMappings;
private final Map> columnMappings;
public TranslatorOptions(Collection keywords) {
this.keywords = keywords;
this.tableMappings = Collections.unmodifiableMap(new HashMap<>());
this.columnMappings = Collections.unmodifiableMap(new HashMap<>());
}
public TranslatorOptions(Collection keywords, Map tableMappings, Map> columnMappings) {
this.keywords = keywords;
this.tableMappings = tableMappings;
this.columnMappings = columnMappings;
}
public Collection getKeywords() {
return keywords;
}
public String tableMapName(String tblName) {
return tableMappings.getOrDefault(tblName, tblName);
}
public String columnMapName(String table, String column) {
if (columnMappings.containsKey(table)) {
return columnMappings.get(table).getOrDefault(column, column);
} else {
return column;
}
}
public static TranslatorOptions empty() {
return new TranslatorOptions(Collections.unmodifiableList(new ArrayList<>()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy