1 16 package org.apache.commons.collections.comparators; 17 18 import java.io.Serializable ; 19 import java.util.Comparator ; 20 21 44 public class ComparableComparator implements Comparator , Serializable { 45 46 47 private static final long serialVersionUID=-291439688585137865L; 48 49 50 private static final ComparableComparator instance = new ComparableComparator(); 51 52 62 public static ComparableComparator getInstance() { 63 return instance; 64 } 65 66 72 public ComparableComparator() { 73 super(); 74 } 75 76 90 public int compare(Object obj1, Object obj2) { 91 return ((Comparable )obj1).compareTo(obj2); 92 } 93 94 102 public int hashCode() { 103 return "ComparableComparator".hashCode(); 104 } 105 106 121 public boolean equals(Object object) { 122 return (this == object) || 123 ((null != object) && (object.getClass().equals(this.getClass()))); 124 } 125 126 } 127 | Popular Tags |