org.apache.commons.collections.comparators |
This package contains implementations of the
{@link java.util.Comparator Comparator} interface.
You may also consider using
{@link org.apache.commons.collections.ComparatorUtils ComparatorUtils},
which is a single class that uses static methods to construct instances
of the classes in this package.
|
Java Source File Name | Type | Comment |
AbstractTestComparator.java | Class | Abstract test class for testing the Comparator interface. |
BooleanComparator.java | Class | A
Comparator for
Boolean objects that can sort either
true or false first. |
ComparableComparator.java | Class | A
Comparator Comparator that compares
Comparable Comparable objects.
This Comparator is useful, for example,
for enforcing the natural order in custom implementations
of SortedSet and SortedMap.
Note: In the 2.0 and 2.1 releases of Commons Collections,
this class would throw a
ClassCastException if
either of the arguments to
ComparableComparator.compare(Object,Object) compare were null , not
Comparable Comparable ,
or for which
Comparable.compareTo(Object) compareTo gave
inconsistent results. |
ComparatorChain.java | Class | A ComparatorChain is a Comparator that wraps one or
more Comparators in sequence. |
FixedOrderComparator.java | Class | A Comparator which imposes a specific order on a specific set of Objects.
Objects are presented to the FixedOrderComparator in a specified order and
subsequent calls to
FixedOrderComparator.compare(Object,Object) compare yield that order.
For example:
String[] planets = {"Mercury", "Venus", "Earth", "Mars"};
FixedOrderComparator distanceFromSun = new FixedOrderComparator(planets);
Arrays.sort(planets); // Sort to alphabetical order
Arrays.sort(planets, distanceFromSun); // Back to original order
Once compare has been called, the FixedOrderComparator is locked
and attempts to modify it yield an UnsupportedOperationException.
Instances of FixedOrderComparator are not synchronized. |
NullComparator.java | Class | A Comparator that will compare nulls to be either lower or higher than
other objects.
since: Commons Collections 2.0 version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $ author: Michael A. |
ReverseComparator.java | Class | Reverses the order of another comparator by reversing the arguments
to its
ReverseComparator.compare(Object,Object) compare method.
since: Commons Collections 2.0 version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $ author: Henri Yandell author: Michael A. |
TestAll.java | Class | Entry point for all Comparator Collections tests. |
TestBooleanComparator.java | Class | Tests for
BooleanComparator . |
TestComparableComparator.java | Class | Tests for ComparableComparator. |
TestComparatorChain.java | Class | Tests for ComparatorChain. |
TestFixedOrderComparator.java | Class | Test class for FixedOrderComparator. |
TestNullComparator.java | Class | Test the NullComparator.
version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $ author: Michael A. |
TestReverseComparator.java | Class | Tests for ReverseComparator. |
TransformingComparator.java | Class | Decorates another Comparator with transformation behavior. |