Slightly scary change, but this makes Name more "correct" - Since equals() cares about the class of the Name and not just the normal string, make compareTo() care about that too. I've set it up so that the specific class of the Name has priority in the sort and thus all the "BuildingName" entries will group together.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6061 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -127,7 +127,13 @@ public class Name extends SimpleStreamableObject
|
||||
// from interface Comparable<Name>
|
||||
public int compareTo (Name other)
|
||||
{
|
||||
return getNormal().compareTo(other.getNormal());
|
||||
Class<?> c = getClass();
|
||||
Class<?> oc = other.getClass();
|
||||
if (c == oc || c.getName().equals(oc.getName())) {
|
||||
return getNormal().compareTo(other.getNormal());
|
||||
} else {
|
||||
return c.getName().compareTo(oc.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user