2.17.2: 2011-06-17

net.sf.basedb.util
Class PriorityComparator<T>

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

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

A comparator implemenation that sorts a given set of objects before all other object.

Since:
2.17
Author:
Nicklas
Last modified
$Date: 2011-02-16 14:49:40 +0100 (Wed, 16 Feb 2011) $

Field Summary
private  Comparator<? super T> parent
           
private  Collection<T> priority
           
 
Constructor Summary
PriorityComparator(Collection<T> priority, Comparator<? super T> parent)
          Create a new comparator.
PriorityComparator(SortedSet<T> priority)
          Create a new comparator using the same sort order as the given sorted set.
 
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

priority

private final Collection<T> priority

parent

private final Comparator<? super T> parent
Constructor Detail

PriorityComparator

public PriorityComparator(Collection<T> priority,
                          Comparator<? super T> parent)
Create a new comparator.

Parameters:
priority - A collection containing the objects that should be sorted first
parent - The parent comparator used to sort the objects

PriorityComparator

public PriorityComparator(SortedSet<T> priority)
Create a new comparator using the same sort order as the given sorted set.

Parameters:
priority - A collection containing the objects that should be sorted first
Method Detail

compare

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

2.17.2: 2011-06-17