SPR-9874 Fix portlet annotation predicate compareTo #164

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

Make compareTo behave correctly for portlet annotation handler predicates for all requirements of the compareTo method contract. If predicates of differing types are compared the class name of the types is used to compute the value returned by compareTo. This ensures consistent ordering of predicates in a sorted collection or array.

SPR-9874 Fix portlet annotation predicate compareTo
Make compareTo behave correctly for all requirements of the
compareTo method contract

Thinking about this further I believe the actual best solution would be to further simplify the comparison and for all predicates where the type does not match fall back to:

return this.getClass().getName().compareTo(other.getClass().getName());

With the hard-coded "return -1;" for comparing non SpecialRequesTypePredicates you could get into a situation where X.compareTo(Y) == -1 and Y.compareTo(X) == -1 which is invalid as well.

@ghost ghost assigned jhoeller Oct 29, 2012

Member

snicoll commented Apr 18, 2014

Closing this one as SPR-9874 has been fixed. Thanks!

@snicoll snicoll closed this Apr 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment