Class ComparatorUtils


  • public class ComparatorUtils
    extends Object
    Helper class containing methods for the comparison between different types.
    • Constructor Detail

      • ComparatorUtils

        public ComparatorUtils()
    • Method Detail

      • compare

        public static int compare​(Comparable o1,
                                  Comparable o2,
                                  int ordering)
        Compares two comparable objects.
        Parameters:
        ordering - : 1=ascending, -1=descending
      • compare

        public static int compare​(Date o1,
                                  Date o2,
                                  int ordering)
        Compares two dates.
        Parameters:
        ordering - : 1=ascending, -1=descending
      • compare

        public static int compare​(Boolean o1,
                                  Boolean o2,
                                  int ordering)
        Compares two booleans.
        Parameters:
        ordering - : 1=ascending, -1=descending
      • compare

        public static int compare​(Collection o1,
                                  Collection o2,
                                  int ordering)
        Compares two collections. A collection is considered greater than other if it has one element greater than all other collection elements.
        Parameters:
        ordering - : 1=ascending, -1=descending
      • compare

        public static int compare​(Object obj,
                                  Collection col,
                                  int ordering)
        Compare an element with the collection elements. The element is greater than the collection if it is greater than ALL of its elements. The element is smaller than the collection if it is smaller than ALL of its elements.
        Parameters:
        ordering - : 1=ascending, -1=descending
      • compare

        public static int compare​(Object o1,
                                  Object o2,
                                  int ordering)
        Compares two objects. Only Object satisfying the following interfaces can be compared: Comparable, Boolean and Collection.
        Parameters:
        ordering - : 1=ascending, -1=descending