-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Refine Specification API #3578
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
Conversation
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?
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 updated the name to unrestricted() to express really what it does.
| 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 and UpdateSpecification. Add PredicateSpecification. Update SpecificationExecutor.
Gentle reminder to deprecate where before we remove it here
Revise nullability requirements around non-nullable specifications.
The where method will be removed with next major version containing some refinements in the Specification API. See: #3578
Also remove serialVersionUID. Original Pull Request: #3578
Revise nullability requirements around non-nullable specifications. Original Pull Request: #3578
Also remove serialVersionUID. Original Pull Request: #3578
Revise nullability requirements around non-nullable specifications. Original Pull Request: #3578
Also remove serialVersionUID. Original Pull Request: #3578
Revise nullability requirements around non-nullable specifications. Original Pull Request: #3578
Introduce
DeleteSpecificationandUpdateSpecification. AddPredicateSpecification. UpdateSpecificationExecutor.See #3521