1 48 package org.exolab.jms.lease; 49 50 import java.util.Comparator ; 51 52 53 60 public class LeaseComparator 61 implements Comparator { 62 63 75 public int compare(Object obj1, Object obj2) { 76 int result = 0; 77 78 if ((obj1 instanceof BaseLease) && 79 (obj2 instanceof BaseLease)) { 80 BaseLease lease1 = (BaseLease) obj1; 81 BaseLease lease2 = (BaseLease) obj2; 82 83 if (lease1.getExpiryTime() != lease2.getExpiryTime()) { 84 if (lease1.getExpiryTime() < lease2.getExpiryTime()) { 85 result = -1; 86 } else { 87 result = 1; 88 } 89 } 90 } else { 91 throw new ClassCastException ("obj1 is of type " + 92 obj1.getClass().getName() + " obj2 is of type " + 93 obj2.getClass().getName()); 94 } 95 96 return result; 97 } 98 99 106 public boolean equals(Object comparator) { 107 return comparator instanceof LeaseComparator; 108 } 109 } 110 111 112 | Popular Tags |