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

com.jpattern.orm.query.where.BinaryExpressionElement Maven / Gradle / Ivy

There is a newer version: 3.5.1
Show newest version
package com.jpattern.orm.query.where;

import java.util.List;

import com.jpattern.orm.query.INameSolver;

/**
 * 
 * @author Francesco Cina
 *
 * 26/giu/2011
 */
public abstract class BinaryExpressionElement implements ExpressionElement{


	/**
	 * 
	 */
	
	private final String relationType;
	protected final ExpressionElement expressionOne;
	protected final ExpressionElement expressionTwo;

	public BinaryExpressionElement(ExpressionElement expressionOne, ExpressionElement expressionTwo, String relationType) {
		this.expressionOne = expressionOne;
		this.expressionTwo = expressionTwo;
		this.relationType = relationType;
	}

	@Override
	public String renderSql() {
		StringBuilder StringBuilder = new StringBuilder();
		renderSql(StringBuilder);
		return StringBuilder.toString();
	}

	@Override
	public void renderSql(StringBuilder StringBuilder) {
		StringBuilder.append("( ");
		expressionOne.renderSql(StringBuilder);
		StringBuilder.append(relationType);
		expressionTwo.renderSql(StringBuilder);
		StringBuilder.append(") ");
	}

	@Override
	public void setNameSolver(INameSolver nameSolver) {
		expressionOne.setNameSolver(nameSolver);
		expressionTwo.setNameSolver(nameSolver);
	}

	@Override
	public void appendValues(List values) {
		expressionOne.appendValues(values);
		expressionTwo.appendValues(values);
	}

}