Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilteredStreamRulePredicate empty does not return true for isEmpty #433

Open
snicoll opened this issue Feb 16, 2023 · 1 comment
Open

FilteredStreamRulePredicate empty does not return true for isEmpty #433

snicoll opened this issue Feb 16, 2023 · 1 comment

Comments

@snicoll
Copy link
Contributor

snicoll commented Feb 16, 2023

I am initializing a predicate to empty to build a list of OR predicates.

I've noticed that applying or on such a predicate with anything leads to the following predicate:

 OR mypredicate

(notice the space before the OR).

I've tried to workaround this by creating the following method:

private static FilteredStreamRulePredicate or(FilteredStreamRulePredicate left, FilteredStreamRulePredicate right) {
    if (left == null || left.isEmpty()) {
        return right;
    }
    return left.or(right);
}

That turned out to not work as even if left is FilteredStreamRulePredicate.empty(), isEmpty returns false.

I am happy to contribute a PR. Besides contributing a fix for the isEmpty check, it would be nice to also fix the composition so that it doesn't apply an operator between two predicates if one of them is empty.

@redouane59
Copy link
Owner

Hello,

Feel free to submit a pull request yes :)
This feature was also added by a contributor a few months ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants