1 23 package com.sun.appserv.management.util.jmx; 24 25 import javax.management.ObjectName ; 26 27 public final class ObjectNameComparator implements java.util.Comparator <ObjectName > 28 { 29 public static final ObjectNameComparator INSTANCE = new ObjectNameComparator(); 30 31 private ObjectNameComparator() {} 32 33 public int 34 compare( final ObjectName o1, final ObjectName o2 ) 35 { 36 int result = 0; 37 38 if ( o1 == null && o2 == null ) 39 { 40 result = 0; 41 } 42 else if ( o1 == null ) 43 { 44 result = -1; 45 } 46 else if ( o2 == null ) 47 { 48 result = 1; 49 } 50 else 51 { 52 final String name1 = JMXUtil.toString( o1 ); 53 final String name2 = JMXUtil.toString( o2 ); 54 55 result = name1.toString().compareTo( name2.toString() ); 56 } 57 58 return result; 59 } 60 61 public boolean 62 equals( final Object other ) 63 { 64 return( other instanceof ObjectNameComparator ); 65 } 66 } 67 68 69 | Popular Tags |