public class ComparableUtils extends Object
Utility library to provide helper methods for translating 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 Comparable<A>>
Provides access to the available methods
|
Modifier and Type | Method and Description |
---|---|
static <A extends 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 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 Comparable<A>> |
ge(A b)
Checks if the tested object is greater than or equal to
b |
static <A extends Comparable<A>> |
gt(A b)
Checks if the tested object is greater than
b |
static <A extends Comparable<A>> |
is(A a)
Provides access to the available methods
|
static <A extends Comparable<A>> |
le(A b)
Checks if the tested object is less than or equal to
b |
static <A extends Comparable<A>> |
lt(A b)
Checks if the tested object is less than
b |
public static <A extends Comparable<A>> 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 Comparable<A>> 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 Comparable<A>> 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 Comparable<A>> 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 Comparable<A>> ComparableUtils.ComparableCheckBuilder<A> is(A a)
A
- type of the base objecta
- base object in the further comparisonpublic static <A extends Comparable<A>> 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 Comparable<A>> 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
Copyright © 2001–2020 The Apache Software Foundation. All rights reserved.