# Class ComparableUtils

java.lang.Object
org.apache.commons.lang3.compare.ComparableUtils

public class ComparableUtils extends Object
Helper translating `Comparable.compareTo(T)` results to booleans.

Example: `boolean x = ComparableUtils.is(myComparable).lessThanOrEqualTo(otherComparable)`

#ThreadSafe#

Since:
  3.10

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `ComparableUtils.ComparableCheckBuilder<A extends Comparable<A>>`
  Compares objects of a given generic type `A`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <A extends Comparable<A>>
  Predicate<A>`
  `between(A b, A c)`
  Creates a predicate to test if `[b <= a <= c]` or `[b >= a >= c]` where the `a` is the tested object.
  `static <A extends Comparable<A>>
  Predicate<A>`
  `betweenExclusive(A b, A c)`
  Creates a predicate to test if `(b < a < c)` or `(b > a > c)` where the `a` is the tested object.
  `static <A extends Comparable<A>>
  Predicate<A>`
  `ge(A b)`
  Creates a predicate to test if the tested object is greater than or equal to `b`
  `static <A extends Comparable<A>>
  Predicate<A>`
  `gt(A b)`
  Creates a predicate to test if the tested object is greater than `b`
  `static <A extends Comparable<A>>
  ComparableUtils.ComparableCheckBuilder<A>`
  `is(A a)`
  Creates a new `ComparableUtils.ComparableCheckBuilder`.
  `static <A extends Comparable<A>>
  Predicate<A>`
  `le(A b)`
  Creates a predicate to test if the tested object is less than or equal to `b`
  `static <A extends Comparable<A>>
  Predicate<A>`
  `lt(A b)`
  Creates a predicate to test if the tested object is less than `b`
  `static <A extends Comparable<A>>
  A`
  `max(A comparable1, A comparable2)`
  Returns the greater of two `Comparable` values, ignoring null.
  `static <A extends Comparable<A>>
  A`
  `min(A comparable1, A comparable2)`
  Returns the lesser of two `Comparable` values, ignoring null.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### between

    public static <A extends Comparable<A>> Predicate<A> between(A b, A c)
    Creates a predicate to test if `[b <= a <= c]` or `[b >= a >= c]` where the `a` is 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

  - ### betweenExclusive

    public static <A extends Comparable<A>> Predicate<A> betweenExclusive(A b, A c)
    Creates a predicate to test if `(b < a < c)` or `(b > a > c)` where the `a` is 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

  - ### ge

    public static <A extends Comparable<A>> Predicate<A> ge(A b)
    Creates a predicate to test if the tested object is greater than or equal to `b`
    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 to `0`

  - ### gt

    public static <A extends Comparable<A>> Predicate<A> gt(A b)
    Creates a predicate to test if the tested object is greater than `b`
    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 `0`

  - ### is

    public static <A extends Comparable<A>> ComparableUtils.ComparableCheckBuilder<A> is(A a)
    Creates a new `ComparableUtils.ComparableCheckBuilder`.
    Type Parameters:
      `A` - type of the base object
    Parameters:
      `a` - base object in the further comparison
    Returns:
      a builder object with further methods

  - ### le

    public static <A extends Comparable<A>> Predicate<A> le(A b)
    Creates a predicate to test if the tested object is less than or equal to `b`
    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 to `0`

  - ### lt

    public static <A extends Comparable<A>> Predicate<A> lt(A b)
    Creates a predicate to test if the tested object is less than `b`
    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 `0`

  - ### max

    public static <A extends Comparable<A>> A max(A comparable1, A comparable2)
    Returns the greater of two `Comparable` values, 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 `comparable1` and `comparable2`.
    Since:
      3.13.0
    See Also:
      - `ObjectUtils.max(Comparable...)`

  - ### min

    public static <A extends Comparable<A>> A min(A comparable1, A comparable2)
    Returns the lesser of two `Comparable` values, 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 `comparable1` and `comparable2`.
    Since:
      3.13.0
    See Also:
      - `ObjectUtils.min(Comparable...)`