java.lang.Object
org.tentackle.common.Compare
Some handy static null-safe methods to compare two
Comparables.- Author:
- harald
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<? super T>>
intcompare(T o1, T o2) Compares two objects.
nullis being treated as smallest value.static <T extends Comparable<? super T>>
intcompareWithNullLargest(T o1, T o2) Compares two objects.
nullis being treated as largest value.
-
Method Details
-
compare
Compares two objects.
nullis being treated as smallest value.Notice the different semantics compared to
Objects.compare(java.lang.Object, java.lang.Object, java.util.Comparator)for null-values.- Type Parameters:
T- the class type- Parameters:
o1- the first objecto2- the second object- Returns:
- a negative integer, zero, or a positive integer as o1 is less than, equal to, or greater than o2.
-
compareWithNullLargest
Compares two objects.
nullis being treated as largest value.- Type Parameters:
T- the class type- Parameters:
o1- the first objecto2- the second object- Returns:
- a negative integer, zero, or a positive integer as o1 is less than, equal to, or greater than o2.
-