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

Provide static type safe methods like Collections.emptyList() for Comparators [SPR-14779] #19345

Closed
spring-projects-issues opened this issue Oct 5, 2016 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Oct 5, 2016

hakamairi opened SPR-14779 and commented

It seems that several of org.springframework.util.comparator package's classes need static methods that would provide a type-safe way of obtaining the INSTANCE (similar to java.util.Collections.emptyList()).

This was already mentioned in #14364 but the changes haven't made it to master.

Instead of referencing ComparableComparator.INSTANCE (which is a raw type) we would be able to use just one @SuppressWarnings on the level of type-safe static method get().

Similarly NullSafeComparator and CompoundComparator should be refactored.

Unnecessary @SuppressWarnings can be refactored from equals methods of Comparators.

CompoundComparator could use some refactoring in general.


Reference URL: #1197

Issue Links:

Referenced from: commits 5f531a7, 9543384

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Oct 5, 2016

hakamairi commented

#1197

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 15, 2017

Juergen Hoeller commented

I've taken a slightly different approach: introducing a Comparators entry point with several such generally typed factory methods. CompoundComparator and InstanceComparator are deprecated now, in favor of standard JDK 8 Comparator.thenComparing and Comparator.reversed; I've also replaced our own use of those classes with the JDK 8 equivalents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants