Package org.apache.commons.lang3.compare
Class ComparableUtils
java.lang.Object
org.apache.commons.lang3.compare.ComparableUtils
Utility library to provide helper methods for translating 
Comparable.compareTo(T) result into a boolean.
 Example: boolean x = is(myComparable).lessThanOrEqualTo(otherComparable)
#ThreadSafe#
- Since:
- 3.10
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classComparableUtils.ComparableCheckBuilder<A extends Comparable<A>>Provides access to the available methods
- 
Method SummaryModifier and TypeMethodDescriptionstatic <A extends Comparable<A>>
 Predicate<A>between(A b, A c) Checks if[b <= a <= c]or[b >= a >= c]where theais the tested object.static <A extends Comparable<A>>
 Predicate<A>betweenExclusive(A b, A c) Checks if(b < a < c)or(b > a > c)where theais the tested object.static <A extends Comparable<A>>
 Predicate<A>ge(A b) Checks if the tested object is greater than or equal tobstatic <A extends Comparable<A>>
 Predicate<A>gt(A b) Checks if the tested object is greater thanbstatic <A extends Comparable<A>>
 ComparableUtils.ComparableCheckBuilder<A>is(A a) Provides access to the available methodsstatic <A extends Comparable<A>>
 Predicate<A>le(A b) Checks if the tested object is less than or equal tobstatic <A extends Comparable<A>>
 Predicate<A>lt(A b) Checks if the tested object is less thanbstatic <A extends Comparable<A>>
 Amax(A comparable1, A comparable2) Returns the greater of twoComparablevalues, ignoring null.static <A extends Comparable<A>>
 Amin(A comparable1, A comparable2) Returns the lesser of twoComparablevalues, ignoring null.
- 
Method Details- 
betweenChecks if[b <= a <= c]or[b >= a >= c]where theais the tested object.- Type Parameters:
- A- type of the test object
- Parameters:
- b- the object to compare to the tested object
- c- the object to compare to the tested object
- Returns:
- a predicate for true if the tested object is between b and c
 
- 
betweenExclusiveChecks if(b < a < c)or(b > a > c)where theais the tested object.- Type Parameters:
- A- type of the test object
- Parameters:
- b- the object to compare to the tested object
- c- the object to compare to the tested object
- Returns:
- a predicate for true if the tested object is between b and c and not equal to those
 
- 
geChecks if the tested object is greater than or equal tob- Type Parameters:
- A- type of the test object
- Parameters:
- b- the object to compare to the tested object
- Returns:
- a predicate for true if the value returned by Comparable.compareTo(T)is greater than or equal to0
 
- 
gtChecks if the tested object is greater thanb- Type Parameters:
- A- type of the test object
- Parameters:
- b- the object to compare to the tested object
- Returns:
- a predicate for true if the value returned by Comparable.compareTo(T)is greater than0
 
- 
isProvides access to the available methods- Type Parameters:
- A- type of the base object
- Parameters:
- a- base object in the further comparison
- Returns:
- a builder object with further methods
 
- 
leChecks if the tested object is less than or equal tob- Type Parameters:
- A- type of the test object
- Parameters:
- b- the object to compare to the tested object
- Returns:
- a predicate for true if the value returned by Comparable.compareTo(T)is less than or equal to0
 
- 
ltChecks if the tested object is less thanb- Type Parameters:
- A- type of the test object
- Parameters:
- b- the object to compare to the tested object
- Returns:
- a predicate for true if the value returned by Comparable.compareTo(T)is less than0
 
- 
maxReturns the greater of twoComparablevalues, ignoring null.For three or more values, use ObjectUtils.max(Comparable...).- Type Parameters:
- A- Type of what we are comparing.
- Parameters:
- comparable1- the first comparable, may be null.
- comparable2- the second comparable, may be null.
- Returns:
- the largest of comparable1andcomparable2.
- Since:
- 3.13.0
- See Also:
 
- 
minReturns the lesser of twoComparablevalues, ignoring null.For three or more values, use ObjectUtils.min(Comparable...).- Type Parameters:
- A- Type of what we are comparing.
- Parameters:
- comparable1- the first comparable, may be null.
- comparable2- the second comparable, may be null.
- Returns:
- the smallest of comparable1andcomparable2.
- Since:
- 3.13.0
- See Also:
 
 
-