Class Comparables


  • public class Comparables
    extends java.lang.Object
    Utility methods for Comparables.
    • Constructor Summary

      Constructors 
      Constructor Description
      Comparables()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int compareIgnoreCase​(java.util.List<java.lang.String> list1, java.util.List<java.lang.String> list2)
      Compare each element in list1 to the corresponding element in list2 until a difference is found.
      static <T extends java.lang.Comparable<? super T>>
      T
      min​(T c1, T... others)
      Find the minimum value of a group of items.
      static <T extends java.lang.Comparable<? super T>>
      int
      nullFirst​(T c1, T c2)
      Compare two possibly null objects.
      static <T extends java.lang.Comparable<? super T>>
      int
      nullLast​(T c1, T c2)
      Compare two possibly null objects.
      • Methods inherited from class java.lang.Object

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

      • Comparables

        public Comparables()
    • Method Detail

      • min

        @SafeVarargs
        public static <T extends java.lang.Comparable<? super T>> T min​(T c1,
                                                                        T... others)
        Find the minimum value of a group of items.
        Parameters:
        c1 - the first item
        others - the remaining items
        Returns:
        the minimum item
      • nullFirst

        public static <T extends java.lang.Comparable<? super T>> int nullFirst​(T c1,
                                                                                T c2)
        Compare two possibly null objects. A null is considered "less than" any non-null value.
        Returns:
        the comparison result
      • nullLast

        public static <T extends java.lang.Comparable<? super T>> int nullLast​(T c1,
                                                                               T c2)
        Compare two possibly null objects. A null is considered "greater than" any non-null value.
        Returns:
        the comparison result
      • compareIgnoreCase

        public static int compareIgnoreCase​(java.util.List<java.lang.String> list1,
                                            java.util.List<java.lang.String> list2)
        Compare each element in list1 to the corresponding element in list2 until a difference is found. If one list contains the leading elements of the other then the comparison result is the difference in the list sizes.
        Returns:
        the result of tne first non-zero comparison of the list elements or the comparison of the list sizes