Package net.sf.basedb.util
Class NameableComparator<T extends Nameable>
java.lang.Object
net.sf.basedb.util.NameableComparator<T>
- All Implemented Interfaces:
Serializable
,Comparator<T>
public class NameableComparator<T extends Nameable> extends Object implements Comparator<T>, Serializable
An implementation of the
Comparator
interface which uses
the name of Nameable
items to compare the objects. If the names
are equal it uses the ID:s to really check if they are equal.
Note: this comparator is consistent 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 NameableComparator(boolean descending)
Create a new comparator. -
Method Summary
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 Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
descending
private final boolean descending
-
-
Constructor Details
-
NameableComparator
public NameableComparator(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 Details
-
compare
- Specified by:
compare
in interfaceComparator<T extends Nameable>
-