net.sf.jga.util
Class ChainedComparator<T>

java.lang.Object
  extended by net.sf.jga.util.ChainedComparator<T>
All Implemented Interfaces:
java.io.Serializable, java.util.Comparator<T>

public class ChainedComparator<T>
extends java.lang.Object
implements java.util.Comparator<T>, java.io.Serializable

Comparator wrapper that uses a pair of comparators internally. The primary comparator is evaluated first, and if it returns 0 (equal), then this returns the result of the secondary comparator.

Author:
David A. Hall
See Also:
Serialized Form

Constructor Summary
ChainedComparator(java.util.Comparator<T> primary, java.util.Comparator<T> secondary)
           
 
Method Summary
 int compare(T x, T y)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

ChainedComparator

public ChainedComparator(java.util.Comparator<T> primary,
                         java.util.Comparator<T> secondary)
Method Detail

compare

public int compare(T x,
                   T y)
Specified by:
compare in interface java.util.Comparator<T>


Copyright © 2002-2006 David A. Hall. All Rights Reserved.