nl.topicus.jdbc.statement.SingleRowWhereClauseValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spanner-jdbc Show documentation
Show all versions of spanner-jdbc Show documentation
JDBC Driver for Google Cloud Spanner
package nl.topicus.jdbc.statement;
import java.util.HashMap;
import java.util.Map;
import nl.topicus.jdbc.MetaDataStore.TableKeyMetaData;
public class SingleRowWhereClauseValidator
{
private final TableKeyMetaData table;
private Map keyValues = new HashMap<>();
private Map keyValuesSet = new HashMap<>();
private String currentColumn = null;
public SingleRowWhereClauseValidator(TableKeyMetaData table)
{
this.table = table;
}
public void set(String column)
{
currentColumn = column.toUpperCase();
}
public void to(Object value)
{
if (currentColumn == null)
throw new IllegalArgumentException("No column set");
keyValues.put(currentColumn, value);
keyValuesSet.put(currentColumn, Boolean.TRUE);
currentColumn = null;
}
public boolean isValid()
{
for (String key : table.getKeyColumns())
{
Boolean set = keyValuesSet.get(key);
if (set == null || !set.booleanValue())
{
return false;
}
}
return true;
}
}