Class LiteralComparator<T extends java.lang.Comparable<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<>()));
    This Comparator 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.
       
      • 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, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • LiteralComparator

        public LiteralComparator​(T[] predefinedOrder)
        Deprecated.
        Constructor.
        Parameters:
        predefinedOrder - Objects that define the order of comparison
    • Method Detail

      • compare

        public int compare​(T o1,
                           T o2)
        Deprecated.
        Specified by:
        compare in interface java.util.Comparator<T extends java.lang.Comparable<T>>