From 50fb782b03307cea36a63ad60542c139b68710e6 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Tue, 27 Apr 2010 01:03:33 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/util/Name.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/util/Name.java b/src/java/com/threerings/util/Name.java index 1758714bc..fcb898302 100644 --- a/src/java/com/threerings/util/Name.java +++ b/src/java/com/threerings/util/Name.java @@ -127,7 +127,13 @@ public class Name extends SimpleStreamableObject // from interface Comparable 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()); + } } /**