001    package util;
002    
003    import java.util.Comparator;
004    
005    /**
006     * A comparator that reverses the order implied by another comparator.
007     *
008     * @author Steffen Zschaler
009     * @version 3.0 12/14/2000
010     * @since v3.0
011     */
012    public final class ReverseOrderComparator extends Object implements Comparator {
013    
014        /**
015         * The original comparator.
016         */
017        private Comparator m_cmpOrg;
018    
019        /**
020         * Creates new ReverseOrderComparator.
021         */
022        public ReverseOrderComparator(Comparator cmpOrg) {
023            super();
024    
025            m_cmpOrg = cmpOrg;
026        }
027    
028        public boolean equals(Object o2) {
029            return (o2 instanceof ReverseOrderComparator) && (((ReverseOrderComparator)o2).m_cmpOrg == m_cmpOrg);
030        }
031    
032        public int compare(final Object o1, final Object o2) {
033            return ( -1) * m_cmpOrg.compare(o1, o2);
034        }
035    }