com.aliasi.util
Class FilterComparator<E>
java.lang.Object
com.aliasi.util.FilterComparator<E>
- All Implemented Interfaces:
- Comparator<E>
- Direct Known Subclasses:
- ReversibleComparator
public class FilterComparator<E>
- extends Object
- implements Comparator<E>
Provides a generic filter for comparators, holding a reference to
a contained comparator and allowing it to be retrieved, and a comparison
operation that delegates to the contained comparator.
- Since:
- LingPipe1.0
- Version:
- 3.0
- Author:
- Bob Carpenter
|
Constructor Summary |
FilterComparator(Comparator<? super E> comparator)
Construct a filter comparator containing the specified
comparator and delegating comparison to it. |
|
Method Summary |
int |
compare(E x1,
E x2)
Return the result of comparing the specified objects using
the contained comparator. |
Comparator<? super E> |
getFilteredComparator()
Returns the comparator being filtered, as provided to the
constructor. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
mComparator
protected final Comparator<? super E> mComparator
- The comparator being filtered.
FilterComparator
public FilterComparator(Comparator<? super E> comparator)
- Construct a filter comparator containing the specified
comparator and delegating comparison to it.
- Parameters:
comparator - The comparator being filtered.
getFilteredComparator
public Comparator<? super E> getFilteredComparator()
- Returns the comparator being filtered, as provided to the
constructor.
- Returns:
- The comparator being filtered, as provided to the
constructor.
compare
public int compare(E x1,
E x2)
- Return the result of comparing the specified objects using
the contained comparator. Subclasses typically override
this implementation.
- Specified by:
compare in interface Comparator<E>
- Parameters:
x1 - First object to compare.x2 - Second object to compare.
- Returns:
- A positive integer if the first object is greater than
the second, a negative integer if the second is greater than
the first, and zero if they are the same.