2.12.0: 2009-05-27

net.sf.basedb.util
Class NameableComparator<T extends Nameable>

java.lang.Object
  extended by net.sf.basedb.util.NameableComparator<T>
All Implemented Interfaces:
Comparator<T>

public class NameableComparator<T extends Nameable>
extends Object
implements Comparator<T>

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
Last modified
$Date: 2008-09-11 22:08:14 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  boolean descending
           
 
Constructor Summary
NameableComparator(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
 

Field Detail

descending

private final boolean descending
Constructor Detail

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 Detail

compare

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

2.12.0: 2009-05-27