Class ComparableUtils

java.lang.Object
io.github.amanzat.util.ComparableUtils

public final class ComparableUtils extends Object
Miscellaneous comparable utility methods.
  • Constructor Details

    • ComparableUtils

      public ComparableUtils()
  • Method Details

    • safeCompare

      public static <T extends Comparable<T>> int safeCompare(T first, T second)
      Does a safe comparison of two Comparable objects accounting for nulls.
      Type Parameters:
      T - The comparable type.
      Parameters:
      first - The first object
      second - The second object
      Returns:
      A positive number if the first object is larger, a negative number if the second object is larger, or 0 if they are equal. Null is considered less than any non-null value.