All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hotrod.runtime.dynamicsql.expressions.VariableExpression Maven / Gradle / Ivy

package org.hotrod.runtime.dynamicsql.expressions;

import java.util.ArrayList;
import java.util.List;

import org.hotrod.runtime.dynamicsql.DynamicSQLEvaluationException;
import org.hotrod.runtime.dynamicsql.DynamicSQLParameters;
import org.hotrod.runtime.dynamicsql.EvaluationFeedback;

public class VariableExpression extends DynamicExpression {

  private String name;

  public VariableExpression(final String name) {
    this.name = name;
  }

  @Override
  public EvaluationFeedback evaluate(final StringBuilder out, final DynamicSQLParameters variables)
      throws DynamicSQLEvaluationException {
    out.append(variables.get(name));
    return new EvaluationFeedback(true);
  }

  @Override
  public List getConstructorParameters() {
    List params = new ArrayList();
    List stringParams = new ArrayList();
    stringParams.add(this.name);
    params.add(stringParams);
    return params;
  }

}