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

com.github.antelopeframework.mybatis.criterion.LogicalExpression Maven / Gradle / Ivy

There is a newer version: 1.1.5
Show newest version
package com.github.antelopeframework.mybatis.criterion;

import lombok.Getter;

/**
 * Superclass of binary logical expressions
 *
 * @author yangzhi.yzh
 * 
 */
@Getter
public class LogicalExpression implements Criterion {
	private static final long serialVersionUID = 1L;
	
	private final Criterion lhs;
	private final Criterion rhs;
	private final String op;

	protected LogicalExpression(Criterion lhs, Criterion rhs, String op) {
		this.lhs = lhs;
		this.rhs = rhs;
		this.op = op;
	}

	@Override
	public String toSqlString(CriteriaQuery criteriaQuery) {
		return '(' + lhs.toSqlString(criteriaQuery) + ' ' + getOp() + ' ' + rhs.toSqlString(criteriaQuery) + ')';
	}

	@Override
	public TypedValue[] getTypedValues(CriteriaQuery criteriaQuery) {
		final TypedValue[] lhsTypedValues = lhs.getTypedValues(criteriaQuery);
		final TypedValue[] rhsTypedValues = rhs.getTypedValues(criteriaQuery);

		final TypedValue[] result = new TypedValue[lhsTypedValues.length + rhsTypedValues.length];
		System.arraycopy(lhsTypedValues, 0, result, 0, lhsTypedValues.length);
		System.arraycopy(rhsTypedValues, 0, result, lhsTypedValues.length, rhsTypedValues.length);
		
		return result;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy