Package com.opencsv.bean.comparator
Class LiteralComparator<T extends java.lang.Comparable<T>>
- java.lang.Object
-
- com.opencsv.bean.comparator.LiteralComparator<T>
-
- Type Parameters:
T
- The type to be sorted
- All Implemented Interfaces:
java.io.Serializable
,java.util.Comparator<T>
@Deprecated public class LiteralComparator<T extends java.lang.Comparable<T>> extends java.lang.Object implements java.util.Comparator<T>, java.io.Serializable
Deprecated.This exact behavior can be had using comparators from Apache Commons Collections, which opencsv includes as a dependency. The following code gives the same result:List<T> predefinedList = Arrays.<T>asList(predefinedOrder); FixedOrderComparator<T> fixedComparator = new FixedOrderComparator<>(predefinedList); fixedComparator.setUnknownObjectBehavior(FixedOrderComparator.UnknownObjectBehavior.AFTER); Comparator<T> c = new ComparatorChain<>(Arrays.<Comparator<T>>asList( fixedComparator, new NullComparator<>(false), new ComparableComparator<>()));
ThisComparator
takes an array of literals that define an order. Anything not included in the array is placed after anything in the array and is then sorted according to its natural order.- Since:
- 4.3
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LiteralComparator(T[] predefinedOrder)
Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
compare(T o1, T o2)
Deprecated.
-
-
-
Constructor Detail
-
LiteralComparator
public LiteralComparator(T[] predefinedOrder)
Deprecated.Constructor.- Parameters:
predefinedOrder
- Objects that define the order of comparison
-
-