Package 

Class Assert

  • All Implemented Interfaces:

    
    public class Assert
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static <T> void nonNull(T expression, String message)
      static void state(boolean state, Supplier<String> messageSupplier) Asserts that the value of state is true.
      static void isTrue(boolean expression, Supplier<String> messageSupplier) Asserts that the given expression is true.
      static void isFalse(boolean expression, Supplier<String> messageSupplier) Asserts that the given expression is false.
      static void notNull(Object value, Supplier<String> messageSupplier) Assert that the given value is not null.
      static <T> T nonNull(T value, Supplier<String> messageSupplier) Assert that the given value is not null.
      static <T, X extends Throwable> void assertThat(T value, Predicate<T> assertion, Supplier<out X> exceptionSupplier) Assert that the given value will result to true through the assertionPredicate.
      static <T, X extends Throwable> void assertNonNull(T value, Supplier<out X> exceptionSupplier) Assert that the given value is non null.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • state

         static void state(boolean state, Supplier<String> messageSupplier)

        Asserts that the value of state is true. If not, an IllegalStateException is thrown.

        Parameters:
        state - the state validation expression
        messageSupplier - Supplier of the exception message if state evaluates to false
      • isTrue

         static void isTrue(boolean expression, Supplier<String> messageSupplier)

        Asserts that the given expression is true. If not, an IllegalArgumentException is thrown.

        Parameters:
        expression - the state validation expression
        messageSupplier - Supplier of the exception message if the expression evaluates to false
      • isFalse

         static void isFalse(boolean expression, Supplier<String> messageSupplier)

        Asserts that the given expression is false. If not, an IllegalArgumentException is thrown.

        Parameters:
        expression - the state validation expression
        messageSupplier - Supplier of the exception message if the expression evaluates to true
      • notNull

         static void notNull(Object value, Supplier<String> messageSupplier)

        Assert that the given value is not null. If not, an IllegalArgumentException is thrown.

        Parameters:
        value - the value not to be null
        messageSupplier - Supplier of the exception message if the assertion fails
      • nonNull

         static <T> T nonNull(T value, Supplier<String> messageSupplier)

        Assert that the given value is not null. If not, an IllegalArgumentException is thrown.

        Parameters:
        value - the value not to be null
        messageSupplier - Supplier of the exception message if the assertion fails
      • assertThat

         static <T, X extends Throwable> void assertThat(T value, Predicate<T> assertion, Supplier<out X> exceptionSupplier)

        Assert that the given value will result to true through the assertionPredicate. If not, the exceptionSupplier provides an exception to be thrown.

        Parameters:
        value - a T specifying the value to assert
        assertion - a Predicate to test value against
        exceptionSupplier - a Supplier of the exception X if assertion evaluates to false
      • assertNonNull

         static <T, X extends Throwable> void assertNonNull(T value, Supplier<out X> exceptionSupplier)

        Assert that the given value is non null. If not, the exceptionSupplier provides an exception to be thrown.

        Parameters:
        value - a T specifying the value to assert
        exceptionSupplier - a Supplier of the exception X if value equals null