Class Comparing

java.lang.Object
org.hisp.dhis.util.Comparing

public class Comparing extends Object
Generic utility class for null-safe comparison.
  • Constructor Details

    • Comparing

      public Comparing()
  • Method Details

    • compareTo

      public static <T extends Comparable<T>> int compareTo(T a, T b)
      Compares two objects for order. Returns a negative integer, zero, or a positive integer if the first object is less than, equal to, or greater than the second object. Any of the objects can be null. A null value is considered to be less than a non-null value.
      Type Parameters:
      T - the type.
      Parameters:
      a - the first object.
      b - the second object.
      Returns:
      an integer value.
    • compareToNullLast

      public static <T extends Comparable<T>> int compareToNullLast(T a, T b)
      Compares two objects for order. Returns a negative integer, zero, or a positive integer if the first object is less than, equal to, or greater than the second object. Any of the objects can be null. A null value is considered to be greater than a non-null value.
      Type Parameters:
      T - the type.
      Parameters:
      a - the first object.
      b - the second object.
      Returns:
      an integer value.