com.jaregu.database.queries.compiling.expr.VariableImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of queries Show documentation
Show all versions of queries Show documentation
Java based SQL templating project. Store your queries in *.sql files and build queries for execution. Supports simple expressions and conditional clauses and interface proxying for java-sql bridge.
package com.jaregu.database.queries.compiling.expr;
import java.util.Collections;
import java.util.List;
public final class VariableImpl extends EvaluableOperand implements Variable {
final private String name;
private List variableNames;
public VariableImpl(String name) {
this.name = name;
this.variableNames = Collections.singletonList(name);
}
@Override
public Object getValue() {
EvaluationContext context = EvaluationContext.getCurrent();
return context.getVariableResolver().toNamed().getValue(name);
}
@Override
public String toString() {
return "${" + name + "}";
}
@Override
public String getName() {
return name;
}
@Override
public List getVariableNames() {
return variableNames;
}
}