-
Notifications
You must be signed in to change notification settings - Fork 302
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
Provide static and/or/xor methods with varargs #805
Comments
I'm not completely sure I understand 🤔 Why do you think Other than that where I see an advantage of the static version is for programmatic use (e.g. I have a set of predicates and I want to AND them, because that's IMHO a little more tedious with the instance method version). But in that case I would definitely also offer a version that takes a collection additionally to the varargs, because nothing is worse in Java than these clunky conversions of collections to arrays 🤪 What is not easy to model at the moment is Anyway, as mentioned I would definitely be open for a static |
Hi @codecholeric, the problem with something like Another problem I see with the In general I think it's good for a predicates DSL to have both styles, as one can pick between the "always left associative" or the nesting case. There is an interesting chapter about it in the DSL book by Martin Fowler (respectively https://martinfowler.com/dslCatalog/functionSequence.html and https://martinfowler.com/dslCatalog/nestedFunction.html).
It is: the exclusivity is important, as i don't want both the annotation and the field, as having both means running twice the extension (from what i know about JUnit 5). I also don't see why i need a second rule, as the xor is exactly describing the situation I want: either one condition or the other, but not both. In other contexts I've also seen the name |
You're right that this is implemented as quite simple chaining without any associativity rules. But to me it's still very clear from an associativity point of view if I do e.g.
I mean, you can add brackets to make it more explicit, right? This seems pretty clear to me that e.g. the last one is Otherwise you would have
In my opinion the Regarding that |
I implemented static factory methods |
Hi all,
I would love to find out what do you think about adding
add(DescribedPredicate, DescribedPredicate, DescribedPredicate...)
,or(DescribedPredicate, DescribedPredicate, DescribedPredicate...)
andxor(DescribedPredicate, DescribedPredicate, DescribedPredicate...)
.The reason I ask for those is that in my use case the instance methods
and
andor
lacks expressiveness and clarity of the static method with variadic arguments. Take this example:The way this is structured in the code is much similar to the way i would do it in a predicate, where I have a couple of subpredicates and the root predicate that wraps all of them.
What do you think?
The text was updated successfully, but these errors were encountered: