Skip to content

Add a FilterOperation to test true/false fields #23

@geraldgole

Description

@geraldgole

It would be nice to have a new FilterOperation type to test boolean fields in database.

Ex : GET /users?deleted=true

Suggested implementation :

public enum BooleanFilterOperation implements IFilterOperation<Boolean> {
    IS_TRUE_FALSE {
        @Override
        public Predicate calculate(CriteriaBuilder cb, Expression<?> expression, Boolean value) {
            return value
                    ? cb.isTrue((Expression<Boolean>) expression)
                    : cb.isFalse((Expression<Boolean>) expression);
        }
    };

    @Override
    public boolean needsMultipleValues() {
        return false;
    }

    @Override
    public Class<Boolean> getOperationType() {
        return Boolean.class;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions