public class ComparableUtils
extends java.lang.Object
Comparable.compareTo(T)
result into a boolean.
Example: boolean x = is(myComparable).lessThanOrEqualTo(otherComparable)
#ThreadSafe#
Modifier and Type | Class and Description |
---|---|
static class |
ComparableUtils.ComparableCheckBuilder<A extends java.lang.Comparable<A>>
Provides access to the available methods
|
Modifier and Type | Method and Description |
---|---|
static <A extends java.lang.Comparable<A>> |
between(A b,
A c)
Checks if
[b <= a <= c] or [b >= a >= c] where the a is the tested object. |
static <A extends java.lang.Comparable<A>> |
betweenExclusive(A b,
A c)
Checks if
(b < a < c) or (b > a > c) where the a is the tested object. |
static <A extends java.lang.Comparable<A>> |
ge(A b)
Checks if the tested object is greater than or equal to
b |
static <A extends java.lang.Comparable<A>> |
gt(A b)
Checks if the tested object is greater than
b |
static <A extends java.lang.Comparable<A>> |
is(A a)
Provides access to the available methods
|
static <A extends java.lang.Comparable<A>> |
le(A b)
Checks if the tested object is less than or equal to
b |
static <A extends java.lang.Comparable<A>> |
lt(A b)
Checks if the tested object is less than
b |
static <A extends java.lang.Comparable<A>> |
max(A comparable1,
A comparable2)
Returns the greater of two
Comparable values, ignoring null. |
static <A extends java.lang.Comparable<A>> |
min(A comparable1,
A comparable2)
Returns the lesser of two
Comparable values, ignoring null. |
public static <A extends java.lang.Comparable<A>> java.util.function.Predicate<A> between(A b, A c)
[b <= a <= c]
or [b >= a >= c]
where the a
is the tested object.A
- type of the test objectb
- the object to compare to the tested objectc
- the object to compare to the tested objectpublic static <A extends java.lang.Comparable<A>> java.util.function.Predicate<A> betweenExclusive(A b, A c)
(b < a < c)
or (b > a > c)
where the a
is the tested object.A
- type of the test objectb
- the object to compare to the tested objectc
- the object to compare to the tested objectpublic static <A extends java.lang.Comparable<A>> java.util.function.Predicate<A> ge(A b)
b
A
- type of the test objectb
- the object to compare to the tested objectComparable.compareTo(T)
is greater than or equal to 0
public static <A extends java.lang.Comparable<A>> java.util.function.Predicate<A> gt(A b)
b
A
- type of the test objectb
- the object to compare to the tested objectComparable.compareTo(T)
is greater than 0
public static <A extends java.lang.Comparable<A>> ComparableUtils.ComparableCheckBuilder<A> is(A a)
A
- type of the base objecta
- base object in the further comparisonpublic static <A extends java.lang.Comparable<A>> java.util.function.Predicate<A> le(A b)
b
A
- type of the test objectb
- the object to compare to the tested objectComparable.compareTo(T)
is less than or equal to 0
public static <A extends java.lang.Comparable<A>> java.util.function.Predicate<A> lt(A b)
b
A
- type of the test objectb
- the object to compare to the tested objectComparable.compareTo(T)
is less than 0
public static <A extends java.lang.Comparable<A>> A max(A comparable1, A comparable2)
Comparable
values, ignoring null.
For three or more values, use ObjectUtils.max(Comparable...)
.
A
- Type of what we are comparing.comparable1
- an argument.comparable2
- another argument.c1
and c2
.ObjectUtils.max(Comparable...)
public static <A extends java.lang.Comparable<A>> A min(A comparable1, A comparable2)
Comparable
values, ignoring null.
For three or more values, use ObjectUtils.min(Comparable...)
.
A
- Type of what we are comparing.comparable1
- an argument.comparable2
- another argument.c1
and c2
.ObjectUtils.min(Comparable...)
Copyright © 2010 - 2023 Adobe. All Rights Reserved