JDK-5036680 : ObjectName should implement Comparable
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-04-23
  • Updated: 2017-05-16
  • Resolved: 2005-04-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b31Fixed
Related Reports
Relates :  
Description
javax.management.ObjectName should implement Comparable<ObjectName>.  Even though it is not very meaningful to say that one ObjectName is "less than" another, by implementing Comparable we would allow a SortedSet<ObjectName> to show its contents in a reasonable order without having to define a custom Comparator.  In particular, ObjectNames with the same domain should be grouped together.

The proposed semantics would be that name1.compareTo(name2) would be the same as name1.getCanonicalName().compareTo(name2.getCanonicalName()).

Comments
EVALUATION Straightforward and obvious change. Implies API change, so cannot be done before Mustang. ###@###.### 2004-04-23 Rather than comparing the canonical names, it might be better to compare the keys in a "smart" order. In particular, it makes sense to compare the "type" key first since it is conventionally present in all ObjectNames. Doing so would allow us to group together MBeans of the same type that are in the same domain. Probably it is enough to leave the key order unspecified but to say that any given implementation will apply a consistent ordering to all keys of all ObjectNames. The purpose, after all, is simply to sort ObjectNames into an order that is convenient for humans. ###@###.### 2005-2-18 16:16:00 GMT
18-02-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
01-09-2004

WORK AROUND Supply an explicit Comparator wherever necessary: public final class ObjectNameComparator implements Comparator<ObjectName> { public int compare(ObjectName o1, ObjectName o2) { return o1.getCanonicalName().compareTo(o2.getCanonicalName()); } public boolean equals(Object o) { return (o instanceof ObjectNameComparator); } }
01-09-2004

PUBLIC COMMENTS javax.management.ObjectName should implement Comparable<ObjectName>. The proposed semantics would be that name1.compareTo(name2) would be the same as name1.getCanonicalName().compareTo(name2.getCanonicalName()).
01-09-2004

SUGGESTED FIX public class ObjectName implements Comparable<ObjectName> { public int compareTo(ObjectName n) { return getCanonicalName().compareTo(n.getCanonicalName()); } } This could be optimized, but it's probably not worth it. ###@###.### 2004-04-23
23-04-2004