01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.util;
11:
12: import java.util.*;
13:
14: /**
15: * The comparator which sorts Comparable on the inverse natural order.
16: *
17: * @author Michiel Meeuwissen
18: * @version $Id: ReverseComparator.java,v 1.1 2007/10/26 11:14:08 michiel Exp $
19: * @since MMBase-1.8.5
20: */
21: public class ReverseComparator implements Comparator<Comparable> {
22:
23: public int compare(Comparable o1, Comparable o2) {
24: return o1 != null ? -1 * o1.compareTo(o2)
25: : (o2 == null ? 0 : 1);
26: }
27:
28: }
|