org.apache.commons.lang3.compare

## Class ComparableUtils

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

-     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#

  Since:
    3.10

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ComparableUtils.ComparableCheckBuilder<A extends Comparable<A>>` Provides access to the available methods

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <A extends Comparable<A>> Predicate<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>> Predicate<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>> Predicate<A>` | `ge(A b)` Checks if the tested object is greater than or equal to `b`
    `static <A extends Comparable<A>> Predicate<A>` | `gt(A b)` Checks if the tested object is greater than `b`
    `static <A extends Comparable<A>> ComparableUtils.ComparableCheckBuilder<A>` | `is(A a)` Provides access to the available methods
    `static <A extends Comparable<A>> Predicate<A>` | `le(A b)` Checks if the tested object is less than or equal to `b`
    `static <A extends Comparable<A>> Predicate<A>` | `lt(A b)` Checks if the tested object is less than `b`

    - ### Methods inherited from class java.lang.Object

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

- - ### Method Detail

    - #### between

          public static <A extends Comparable<A>> Predicate<A> between(A b,
                                                                       A c)

      Checks 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)

      Checks 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)

      Checks 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)

      Checks 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)

      Provides 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

    - #### le

          public static <A extends Comparable<A>> Predicate<A> le(A b)

      Checks 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)

      Checks 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`

Copyright © 2001–2020 The Apache Software Foundation. All rights reserved.