Package io.github.amanzat.util
Class ComparableUtils
java.lang.Object
io.github.amanzat.util.ComparableUtils
Miscellaneous comparable utility methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
intsafeCompare(T first, T second) Does a safe comparison of twoComparableobjects accounting for nulls.
-
Constructor Details
-
ComparableUtils
public ComparableUtils()
-
-
Method Details
-
safeCompare
Does a safe comparison of twoComparableobjects accounting for nulls.- Type Parameters:
T- The comparable type.- Parameters:
first- The first objectsecond- 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.
-