W
Wojtek
I have the following code:
----------------------------------
public enum Type implements Comparable<Type>
{
TYPE_A("a"),TYPE_B("b");
private String sortOrder;
private Type( String sort )
{
sortOrder=sort;
}
private String getSort()
{
return sortOrder;
}
@Override
public int compareTo(Type type)
{
return getSort().compareTo(type.getSort());
}
}
----------------------------------
However it seems that enum has a compareTo method which is final, so I
cannot implement my own sort order when I use the enum as a key in a
TreeMap.
Why is this?
----------------------------------
public enum Type implements Comparable<Type>
{
TYPE_A("a"),TYPE_B("b");
private String sortOrder;
private Type( String sort )
{
sortOrder=sort;
}
private String getSort()
{
return sortOrder;
}
@Override
public int compareTo(Type type)
{
return getSort().compareTo(type.getSort());
}
}
----------------------------------
However it seems that enum has a compareTo method which is final, so I
cannot implement my own sort order when I use the enum as a key in a
TreeMap.
Why is this?