Skip to content

Custom Predicate With 2 Arguments #49

Closed
@DiogoSouza123

Description

@DiogoSouza123

Hi,
Is there any way to create a custom predicate with two arguments?
I need to recreate de operator between, for use into dates because my database uses datetime type and I need to truncate the hour to work as expected.

public static RSQLCustomPredicate<Date> customPredicateBetweenDate() {
    String nameFunctionDatabase = "BETWEEN";

    String nameQueryUrl = "=dbt=";

    return new RSQLCustomPredicate<>(new ComparisonOperator( nameQueryUrl ), Date.class, input -> {
        Expression<Date> function = input.getCriteriaBuilder().function(nameFunctionDatabase , Date.class, input.getPath());
        return input.getCriteriaBuilder().between(function,(Date) input.getArguments().get(0), (Date) input.getArguments().get(1));
    });
}

The way above expects just one argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions