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

com.github.wz2cool.dynamic.builder.BaseConditionClauseBuilder Maven / Gradle / Ivy

There is a newer version: 3.2.32
Show newest version
package com.github.wz2cool.dynamic.builder;

import com.github.wz2cool.dynamic.FilterCondition;
import com.github.wz2cool.dynamic.builder.opeartor.IFilterOperator;
import com.github.wz2cool.dynamic.lambda.*;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Frank
 */
public abstract class BaseConditionClauseBuilder, T> {

    final List> conditionClauseBuilders = new ArrayList<>();

    // and

    @SafeVarargs
    public final E and(
            GetBigDecimalPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E and(
            GetBytePropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E and(
            GetDatePropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E and(
            GetDoublePropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E and(
            GetFloatPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E and(
            GetIntegerPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E and(
            GetLongPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E and(
            GetShortPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E and(
            GetStringPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.AND, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    // or

    @SafeVarargs
    public final E or(
            GetBigDecimalPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E or(
            GetBytePropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E or(
            GetDatePropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E or(
            GetDoublePropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E or(
            GetFloatPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E or(
            GetIntegerPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E or(
            GetLongPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E or(
            GetShortPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SafeVarargs
    public final E or(
            GetStringPropertyFunction getPropertyFunction, IFilterOperator filterOperator,
            ConditionClauseBuilder... conditionClauseBuilders) {
        return andOrInternal(FilterCondition.OR, getPropertyFunction, filterOperator, conditionClauseBuilders);
    }

    @SuppressWarnings("unchecked")
     E andOrInternal(
            FilterCondition condition,
            GetPropertyFunction getPropertyFunction,
            IFilterOperator operator,
            ConditionClauseBuilder[] subConditionClauseBuilders) {
        ConditionClauseBuilder conditionClauseBuilder = new ConditionClauseBuilder<>(
                condition, getPropertyFunction, operator, subConditionClauseBuilders);
        conditionClauseBuilders.add(conditionClauseBuilder);
        return (E) this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy