Package net.sf.basedb.util
Class ToStringComparator<T>
- java.lang.Object
-
- net.sf.basedb.util.ToStringComparator<T>
-
- All Implemented Interfaces:
Serializable
,Comparator<T>
public class ToStringComparator<T> extends Object implements Comparator<T>, Serializable
An implementation of theComparator
interface which uses the result of thetoString
method to compare the objects. Ie. by using this comparator objects are sorted according to thetoString()
values.Note: this comparator may impose orderings that are inconsistent with equals.
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Serialized Form
- Last modified
- $Date: 2010-08-13 10:50:27 +0200 (fr, 13 aug 2010) $
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
descending
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description ToStringComparator(boolean descending)
Create a new comparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
descending
private final boolean descending
-
-
Method Detail
-
compare
public int compare(T o1, T o2)
- Specified by:
compare
in interfaceComparator<T>
-
-