Class DefaultCellComparator

  • All Implemented Interfaces:
    CellComparator

    public final class DefaultCellComparator
    extends AbstractCellComparator
    A default cell comparator.

    Verifies that the objects being compared are the same class. Looks to see if the objects being compared implement comparable and, if so, delegates to that; otherwise, implements a lexicographical compare function (i.e. string sorting). Uses the objects' toString() method and then compares the resulting strings. Note that null values are acceptable and are considered "smaller" than any non-null value.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static CellComparator INSTANCE
      An instance of this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int nonNullCompare​(java.lang.Object o1, java.lang.Object o2)
      Compares its two arguments for order.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

        public static final CellComparator INSTANCE
        An instance of this class.
    • Method Detail

      • nonNullCompare

        protected int nonNullCompare​(java.lang.Object o1,
                                     java.lang.Object o2)
        Description copied from class: AbstractCellComparator
        Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

        Note that both objects are guaranteed to be non-null.

        Specified by:
        nonNullCompare in class AbstractCellComparator
        Parameters:
        o1 - the first object to be compared
        o2 - the second object to be compared
        Returns:
        an integer representing relative ordering
        See Also:
        Comparator.compare(Object, Object)