compareTo is final in Enum...

OK, so I have an enum with about 15 types in it, representing elements such as water, grass, fire and such. I made the enum implement Comparable and rewrote the compareTo method. BUT apparently compareTo is final and I am not allowed to override it. The final version of compareTo compares them based on their ordering, but there is no logical way to order the types so that the relationships are modeled correctly. For example, the ordering

WATER FIRE GRASS GROUND…

water is strong to fire, fire is strong to grass and grass is strong to ground. BUT water is also strong to ground, and grass is strong to water…

the obvious option is to write a different method called compareTypes( Type ) or something to that effect but it feels wrong. It feels broken… I really wanted a compareTo method…

It sounds like you were planning on breaking the contract of Comparable anyway. It’s intended for total orderings.

Ah, I’ve just read through the Comparable interface’s API and it somewhat makes sense now. So what I really want is my own original method compareTypes because compareTo is designed so that it sets the elements in a specific order for sorting maps and the like. I get it. I feel better about writing my own method now. Thanks.