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

org.fingertip.simpledao.query.AbstractCriteria Maven / Gradle / Ivy

The newest version!
package org.fingertip.simpledao.query;

import org.fingertip.simpledao.enums.CriteriaType;

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

/**
 * 条件查询的抽象类
 * 	条件查询的底层业务处理,如:
 * 	收集查询条件
 * @author W.C.H
 *
 */
public abstract class AbstractCriteria implements ICriteria,IAggCriteria {
	private CriteriaType criteriaType;
	private List values = new ArrayList<>(); 
	private String sql;

	public CriteriaType getCriteriaType() {
		return criteriaType;
	}

	public void setCriteriaType(CriteriaType criteriaType) {
		this.criteriaType = criteriaType;
	}

	public List getValues() {
		return values;
	}

	public void setValues(List values) {
		this.values = values;
	}

	public String getSql() {
		return sql;
	}

	public void setSql(String sql) {
		this.sql = sql;
	}

	public AbstractCriteria build(CriteriaType criteriaType, String sql, Object... values){
		this.criteriaType = criteriaType;
		this.sql = sql;
		if(values != null && values.length > 0){
			Collections.addAll(this.values, values);
		}
		return this;
	}
	
	public AbstractCriteria build(CriteriaType criteriaType, String sql, List values){
		this.criteriaType = criteriaType;
		this.sql = sql;
		if(values != null && !values.isEmpty()){
			this.values.addAll(values);
		}
		return this;
	}

	
}