Class FluentCompareTo<T extends Comparable<? super T>>

java.lang.Object
org.xrpl.xrpl4j.model.immutables.FluentCompareTo<T>

public class FluentCompareTo<T extends Comparable<? super T>> extends Object
Provides a fluent, readable alternative to Comparable.compareTo(Object). Instead of code like someValue.compareTo(someOtherValue) <= 0 you can write is(someValue).lessThanOrEqualTo(someOtherValue) . Also provides stronger type safety so you can't accidentally compare apples to oranges.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    between(T startInclusive, T endExclusive)
    Checks if wrapped value is between two given values (inclusive lower bound, exclusive upper bound).
    boolean
    betweenExclusive(T startExclusive, T endExclusive)
    Checks if wrapped value is between 2 given values (exclusive lower bound, exclusive upper bound).
    boolean
    equalTo(T other)
    Checks if wrapped value is equal than the given one.
    Get the underlying value of this FluentCompareTo.
    boolean
    greaterThan(T other)
    Checks if wrapped value is greater than than the given one.
    boolean
    Checks if wrapped value is greater than or equal to than the given one.
    static <T extends Comparable<? super T>>
    FluentCompareTo<T>
    is(T value)
    Create a FluentCompareTo for the given value.
    static <T extends Comparable<? super T>>
    FluentCompareTo<T>
    isNot(T value)
    Create a FluentCompareTo for the given value.
    boolean
    lessThan(T other)
    Checks if wrapped value is less than than the given one.
    boolean
    Checks if wrapped value is less than or equal to than the given one.
    boolean
    notBetween(T startInclusive, T endExclusive)
    Checks if wrapped value is not between two given values (inclusive lower bound, exclusive upper bound).
    boolean
    notBetweenExclusive(T startExclusive, T endExclusive)
    Checks if wrapped value is not between two given values (exclusive lower bound, exclusive upper bound).
    boolean
    notEqualTo(T other)
    Checks if wrapped value is not equal than the given one.
    boolean
    Checks if wrapped value is not greater than than the given one.
    boolean
    Checks if wrapped value is not greater than or equal to than the given one.
    boolean
    notLessThan(T other)
    Checks if wrapped value is not less than than the given one.
    boolean
    Checks if wrapped value is not less than or equal to than the given one.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • is

      public static <T extends Comparable<? super T>> FluentCompareTo<T> is(T value)
      Create a FluentCompareTo for the given value.
      Type Parameters:
      T - the Java type of the wrapped value
      Parameters:
      value - value to wrap
      Returns:
      wrapped value
    • isNot

      public static <T extends Comparable<? super T>> FluentCompareTo<T> isNot(T value)
      Create a FluentCompareTo for the given value.
      Type Parameters:
      T - the Java type of the wrapped value
      Parameters:
      value - value to wrap
      Returns:
      wrapped value
    • equalTo

      public boolean equalTo(T other)
      Checks if wrapped value is equal than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is equal to given value
    • notEqualTo

      public boolean notEqualTo(T other)
      Checks if wrapped value is not equal than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is not equal to given value
    • lessThan

      public boolean lessThan(T other)
      Checks if wrapped value is less than than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is less than given value
    • notLessThan

      public boolean notLessThan(T other)
      Checks if wrapped value is not less than than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is not less than given value
    • lessThanOrEqualTo

      public boolean lessThanOrEqualTo(T other)
      Checks if wrapped value is less than or equal to than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is less than or equal given value
    • notLessThanOrEqualTo

      public boolean notLessThanOrEqualTo(T other)
      Checks if wrapped value is not less than or equal to than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is not less than or equal given value
    • greaterThan

      public boolean greaterThan(T other)
      Checks if wrapped value is greater than than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is greater than given value
    • notGreaterThan

      public boolean notGreaterThan(T other)
      Checks if wrapped value is not greater than than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is not greater than given value
    • greaterThanEqualTo

      public boolean greaterThanEqualTo(T other)
      Checks if wrapped value is greater than or equal to than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is greater than given value
    • notGreaterThanEqualTo

      public boolean notGreaterThanEqualTo(T other)
      Checks if wrapped value is not greater than or equal to than the given one.
      Parameters:
      other - given value
      Returns:
      true if wrapped value is not greater than given value
    • between

      public boolean between(T startInclusive, T endExclusive)
      Checks if wrapped value is between two given values (inclusive lower bound, exclusive upper bound).
      Parameters:
      startInclusive - lower bound inclusive value
      endExclusive - upper bound exclusive value
      Returns:
      true if not between
    • notBetween

      public boolean notBetween(T startInclusive, T endExclusive)
      Checks if wrapped value is not between two given values (inclusive lower bound, exclusive upper bound).
      Parameters:
      startInclusive - lower bound inclusive value
      endExclusive - upper bound exclusive value
      Returns:
      true if not between
    • betweenExclusive

      public boolean betweenExclusive(T startExclusive, T endExclusive)
      Checks if wrapped value is between 2 given values (exclusive lower bound, exclusive upper bound).
      Parameters:
      startExclusive - lower bound exclusive value
      endExclusive - upper bound exclusive value
      Returns:
      true if between
    • notBetweenExclusive

      public boolean notBetweenExclusive(T startExclusive, T endExclusive)
      Checks if wrapped value is not between two given values (exclusive lower bound, exclusive upper bound).
      Parameters:
      startExclusive - lower bound exclusive value
      endExclusive - upper bound exclusive value
      Returns:
      true if not between
    • getValue

      public T getValue()
      Get the underlying value of this FluentCompareTo.
      Returns:
      This FluentCompareTo's underlying value, as type FluentCompareTo.