com.github.wz2cool.dynamic.builder.WhereClauseBuilder Maven / Gradle / Ivy
package com.github.wz2cool.dynamic.builder;
import com.github.wz2cool.dynamic.BaseFilterDescriptor;
import com.github.wz2cool.dynamic.DynamicQuery;
import com.github.wz2cool.dynamic.FilterCondition;
import com.github.wz2cool.dynamic.builder.direction.ISortDirection;
import com.github.wz2cool.dynamic.builder.opeartor.IFilterOperator;
import com.github.wz2cool.dynamic.lambda.GetCommonPropertyFunction;
import com.github.wz2cool.dynamic.lambda.GetPropertyFunction;
/**
* @author Frank
*/
public class WhereClauseBuilder
extends BaseConditionClauseBuilder, T>
implements IDynamicQueryBuilder {
private final DynamicQueryBuilder dynamicQueryBuilder;
public WhereClauseBuilder(
DynamicQueryBuilder dynamicQueryBuilder,
GetPropertyFunction getPropertyFunction,
IFilterOperator operator,
ConditionClauseBuilder[] conditionClauseBuilders) {
this.dynamicQueryBuilder = dynamicQueryBuilder;
dynamicQueryBuilder.setWhereClauseBuilder(this);
andOrInternal(FilterCondition.AND, getPropertyFunction, operator, conditionClauseBuilders);
}
public OrderByClauseBuilder orderBy(GetCommonPropertyFunction getPropertyFunction) {
return new OrderByClauseBuilder<>(dynamicQueryBuilder, getPropertyFunction);
}
public OrderByClauseBuilder orderBy(GetCommonPropertyFunction getPropertyFunction, ISortDirection direction) {
return new OrderByClauseBuilder<>(dynamicQueryBuilder, getPropertyFunction, direction);
}
@Override
public DynamicQuery build() {
return dynamicQueryBuilder.build();
}
BaseFilterDescriptor[] getFilters() {
return this.conditionClauseBuilders.stream().map(ConditionClauseBuilder::toFilter)
.toArray(BaseFilterDescriptor[]::new);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy