ComparableUtils
- public class org.apache.commons.lang3.compare.ComparableUtils[source]
Helper translating
Comparable#compareToresults to booleans.Example:
boolean x = ComparableUtils.is(myComparable).lessThanOrEqualTo(otherComparable)#ThreadSafe#
- Since:
3.10
Methods
Creates a predicate to test if |
|
Creates a predicate to test if |
|
Creates a predicate to test if the tested object is greater than or equal to |
|
Creates a predicate to test if the tested object is greater than |
|
Creates a new |
|
Creates a predicate to test if the tested object is less than or equal to |
|
Creates a predicate to test if the tested object is less than |
|
Returns the greater of two |
|
Returns the lesser of two |
- public static <A extends Comparable<A>> Predicate<A> between(A b, A c)[source]
Creates a predicate to test if
[b <= a <= c]or[b >= a >= c]where theais the tested object.- Parameters:
b – The object to compare to the tested object
c – The object to compare to the tested object
- Type parameters:
<A> – type of the test object
- Returns:
A predicate for true if the tested object is between b and c
- public static <A extends Comparable<A>> Predicate<A> betweenExclusive(A b, A c)[source]
Creates a predicate to test if
(b < a < c)or(b > a > c)where theais the tested object.- Parameters:
b – The object to compare to the tested object
c – The object to compare to the tested object
- Type parameters:
<A> – type of the test object
- Returns:
A predicate for true if the tested object is between b and c and not equal to those
- public static <A extends Comparable<A>> Predicate<A> ge(A b)[source]
Creates a predicate to test if the tested object is greater than or equal to
b- Parameters:
b – The object to compare to the tested object
- Type parameters:
<A> – type of the test object
- Returns:
A predicate for true if the value returned by
Comparable#compareTois greater than or equal to0
- public static <A extends Comparable<A>> Predicate<A> gt(A b)[source]
Creates a predicate to test if the tested object is greater than
b- Parameters:
b – The object to compare to the tested object
- Type parameters:
<A> – type of the test object
- Returns:
A predicate for true if the value returned by
Comparable#compareTois greater than0
- public static <A extends Comparable<A>> ComparableUtils.ComparableCheckBuilder<A> is(A a)[source]
Creates a new
ComparableCheckBuilder.- Parameters:
a – base object in the further comparison
- Type parameters:
<A> – type of the base object
- Returns:
A builder object with further methods
- public static <A extends Comparable<A>> Predicate<A> le(A b)[source]
Creates a predicate to test if the tested object is less than or equal to
b- Parameters:
b – The object to compare to the tested object
- Type parameters:
<A> – type of the test object
- Returns:
A predicate for true if the value returned by
Comparable#compareTois less than or equal to0
- public static <A extends Comparable<A>> Predicate<A> lt(A b)[source]
Creates a predicate to test if the tested object is less than
b- Parameters:
b – The object to compare to the tested object
- Type parameters:
<A> – type of the test object
- Returns:
A predicate for true if the value returned by
Comparable#compareTois less than0
- public static <A extends Comparable<A>> A max(A comparable1, A comparable2)[source]
Returns the greater of two
Comparablevalues, 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.- See also:
- Since:
3.13.0
- public static <A extends Comparable<A>> A min(A comparable1, A comparable2)[source]
Returns the lesser of two
Comparablevalues, 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.- See also:
- Since:
3.13.0