Class ComparableSubject<T extends Comparable<?>>

    • Constructor Detail

      • ComparableSubject

        protected ComparableSubject​(FailureMetadata metadata,
                                    @Nullable T actual)
        The constructor is for use by subclasses only. If you want to create an instance of this class itself, call check(...).that(actual).
    • Method Detail

      • isIn

        public final void isIn​(@Nullable Range<T> range)
        Checks that the actual value is in range.
      • isNotIn

        public final void isNotIn​(@Nullable Range<T> range)
        Checks that the actual value is not in range.
      • isEquivalentAccordingToCompareTo

        public void isEquivalentAccordingToCompareTo​(@Nullable T expected)
        Checks that the actual value is equivalent to other according to Comparable.compareTo(T), (i.e., checks that a.comparesTo(b) == 0).

        Note: Do not use this method for checking object equality. Instead, use Subject.isEqualTo(Object).

      • isGreaterThan

        public final void isGreaterThan​(@Nullable T other)
        Checks that the actual value is greater than other.

        To check that the actual value is greater than or equal to other, use isAtLeast(T).

      • isLessThan

        public final void isLessThan​(@Nullable T other)
        Checks that the actual value is less than other.

        To check that the actual value is less than or equal to other, use isAtMost(T).

      • isAtMost

        public final void isAtMost​(@Nullable T other)
        Checks that the actual value is less than or equal to other.

        To check that the actual value is strictly less than other, use isLessThan(T).

      • isAtLeast

        public final void isAtLeast​(@Nullable T other)
        Checks that the actual value is greater than or equal to other.

        To check that the actual value is strictly greater than other, use isGreaterThan(T).