Last update: 2011-06-23

org.proteios.util
Class ToStringComparator<T>

java.lang.Object
  extended by org.proteios.util.ToStringComparator<T>
All Implemented Interfaces:
Comparator<T>

public class ToStringComparator<T>
extends Object
implements Comparator<T>

An implementation of the Comparator interface which uses the result of the toString method to compare the objects. Ie. by using this comparator objects are sorted according to the toString() values.

Note: this comparator may impose orderings that are inconsistent with equals.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Constructor Summary
ToStringComparator(boolean descending)
          Create a new comparator.
 
Method Summary
 int compare(T o1, T o2)
           
 
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

ToStringComparator

public ToStringComparator(boolean descending)
Create a new comparator.

Parameters:
descending - TRUE to sort objects in descending order (z--a), FALSE to sort the objects in ascending order (a--z)
Method Detail

compare

public int compare(T o1,
                   T o2)
Specified by:
compare in interface Comparator<T>

Last update: 2011-06-23