Package io.github.jonestimd.lang
Class Comparables
- java.lang.Object
-
- io.github.jonestimd.lang.Comparables
-
public class Comparables extends java.lang.Object
Utility methods forComparable
s.
-
-
Constructor Summary
Constructors Constructor Description Comparables()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
compareIgnoreCase(java.util.List<java.lang.String> list1, java.util.List<java.lang.String> list2)
Compare each element inlist1
to the corresponding element inlist2
until a difference is found.static <T extends java.lang.Comparable<? super T>>
Tmin(T c1, T... others)
Find the minimum value of a group of items.static <T extends java.lang.Comparable<? super T>>
intnullFirst(T c1, T c2)
Compare two possibly null objects.static <T extends java.lang.Comparable<? super T>>
intnullLast(T c1, T c2)
Compare two possibly null objects.
-
-
-
Method Detail
-
min
@SafeVarargs public static <T extends java.lang.Comparable<? super T>> T min(T c1, T... others)
Find the minimum value of a group of items.- Parameters:
c1
- the first itemothers
- the remaining items- Returns:
- the minimum item
-
nullFirst
public static <T extends java.lang.Comparable<? super T>> int nullFirst(T c1, T c2)
Compare two possibly null objects. Anull
is considered "less than" any non-null
value.- Returns:
- the comparison result
-
nullLast
public static <T extends java.lang.Comparable<? super T>> int nullLast(T c1, T c2)
Compare two possibly null objects. Anull
is considered "greater than" any non-null
value.- Returns:
- the comparison result
-
compareIgnoreCase
public static int compareIgnoreCase(java.util.List<java.lang.String> list1, java.util.List<java.lang.String> list2)
Compare each element inlist1
to the corresponding element inlist2
until a difference is found. If one list contains the leading elements of the other then the comparison result is the difference in the list sizes.- Returns:
- the result of tne first non-zero comparison of the list elements or the comparison of the list sizes
-
-