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

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

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

import java.util.List;

import com.jpattern.orm.query.NameSolver;
import com.jpattern.orm.query.SmartRenderableSqlSubElement;

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


	/**
	 * 
	 */

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

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

	@Override
	public final int getElementStatusVersion() {
		return 0;
	}

	@Override
	public final void doElementRender(final StringBuilder stringBuilder) {
		stringBuilder.append("( ");
		this.expressionOne.renderSqlElement(stringBuilder);
		stringBuilder.append(this.relationType);
		this.expressionTwo.renderSqlElement(stringBuilder);
		stringBuilder.append(") ");
	}

	@Override
	public void setNameSolver(final NameSolver nameSolver) {
		this.expressionOne.setNameSolver(nameSolver);
		this.expressionTwo.setNameSolver(nameSolver);
	}

	@Override
	public final void appendElementValues(final List values) {
		this.expressionOne.appendElementValues(values);
		this.expressionTwo.appendElementValues(values);
	}

}