-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Refine Specification API #3578
base: main
Are you sure you want to change the base?
Refine Specification API #3578
Conversation
Introduce DeleteSpecification and UpdateSpecification. Add PredicateSpecification. Update SpecificationExecutor.
Gentle reminder to deprecate where before we remove it here
Revise nullability requirements around non-nullable specifications.
52ee55f
to
61e6d36
Compare
LGTM |
return (root, query, builder) -> { | ||
|
||
Predicate not = spec.toPredicate(root, query, builder); | ||
return not != null ? builder.not(not) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's so many not's, it's making knots in my brain. Could we at least reverse the comparison?
static <T> Specification<T> anyOf(Iterable<Specification<T>> specifications) { | ||
|
||
return StreamSupport.stream(specifications.spliterator(), false) // | ||
.reduce(Specification.all(), Specification::or); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really wrong to me. Specification.all()
suggests a Specification
that produces true
for all inputs, which would always yield true
when combined by OR
with anything else.
I'd say the underlying problem is that all()
is a misnomer. It should really be Specification.null()
or Specification.empty()
, shouldn't it?
public interface UpdateSpecification<T> extends Serializable { | ||
|
||
/** | ||
* Simple static factory method to create a specification deleting all objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that should read "updating all objects"
* @param spec must not be {@literal null}. | ||
* @return guaranteed to be not {@literal null}. | ||
*/ | ||
static <T> UpdateOperation<T> update(UpdateOperation<T> spec) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments and error message talk about UpdateSpecification
but the types used are UpdateOperation
. I'm confused.
Introduce
DeleteSpecification
andUpdateSpecification
. AddPredicateSpecification
. UpdateSpecificationExecutor
.See #3521