1 19 package org.openide.util.lookup; 20 21 import java.util.Comparator ; 22 import org.openide.util.lookup.AbstractLookup.Pair; 23 24 25 29 final class ALPairComparator implements Comparator <Pair<?>> { 30 public static final Comparator <Pair<?>> DEFAULT = new ALPairComparator(); 31 32 33 private ALPairComparator() { 34 } 35 36 38 public int compare(Pair<?> i1, Pair<?> i2) { 39 int result = i1.getIndex() - i2.getIndex(); 40 41 if (result == 0) { 42 if (i1 != i2) { 43 java.io.ByteArrayOutputStream bs = new java.io.ByteArrayOutputStream (); 44 java.io.PrintStream ps = new java.io.PrintStream (bs); 45 46 ps.println( 47 "Duplicate pair in tree" + "Pair1: " + i1 + " pair2: " + i2 + " index1: " + i1.getIndex() + " index2: " + 49 i2.getIndex() +" item1: " + i1.getInstance() + " item2: " + i2.getInstance() +" id1: " + Integer.toHexString(System.identityHashCode(i1)) +" id2: " + Integer.toHexString(System.identityHashCode(i2)) ); 54 55 ps.close(); 57 58 throw new IllegalStateException (bs.toString()); 59 } 60 61 return 0; 62 } 63 64 return result; 65 } 66 } 67 | Popular Tags |