« first day (1616 days earlier)      last day (3328 days later) » 

fge
11:20 PM
No, it's not
Of course it's not
What is expected by .sort()?
 
I know why it compiles and this could have been easily avoided by providing these 3 constants in a class
 
fge
What?
OK, answer my initial question
What is expected by the .sort() method of a Stream<?>?
And when has Comparable been defined?
If you answer those two questions, you have your answer
 
My answer to what?
 
fge
As to why Comparable's .compareTo() (and Comparator's .compare()) returns an integer, not an enum value
What is more it seems like you don't understand what enums really are
 
Hold on. Why it's related to my initial concern? I'm not sure we are on the same line there...
 
fge
11:27 PM
We are
Comparable, the interface, was defined before enums kicked in
And in Java, enums are not just "typed discrete values"
They are much more than that
You are aware that enums have constructors, right?
And that they can implement interfaces?
AND that they implement... Comparable... Of themselves?
 
11:40 PM
ok and what it should prevent to implement this comparison by returning an enum
something like this:
 
hey guys
has anyone used RestTemplate before?
 
Hello!
 
fge
@AlexisC. chicken and egg
Quite simply
Don't forget that any E extends Enum<E> also implements Comparable<? super E>
In short --> what you ask for is not only impossible, but this would have broken backwards compatibility if it were implemented at all
And we know how the JDK guys regard compatibility -- the topmost priority
 
@fge I was in an hypothesis if enums were introduced at the same time...
But it could have been done with a class and three final constants
 
fge
Well, if they were and they implemented Comparable, same problem: chicken and egg
And let's be honest, the Comparable/Comparator contract is sensible
 
11:55 PM
So I DO understand what enums are btw and it would have been largely better if it would has been designed this way, IMO
well on that i'm going to sleep
 

« first day (1616 days earlier)      last day (3328 days later) »