Package me.sbasalaev

Class Assert

java.lang.Object
me.sbasalaev.Assert

public final class Assert extends Object
Assertions in code. All methods throw AssertionError if the corresponding tests fail. To check the preconditions of methods and constructors where the exceptional situation is the caller's fault for not following method contract use Require instead. The method names are chosen so that Assert class itself is imported rather than individual methods, e.g.
var list = List.of("A", "B", "C");
Assert.that(list.last().equals("C"));
See Also:
  • Method Details

    • that

      public static void that(boolean expression)
      Asserts given expression is true.
      Parameters:
      expression - the expression to be checked.
      Throws:
      AssertionError - if expression is false.
    • not

      public static void not(boolean expression)
      Asserts given expression is false.
      Parameters:
      expression - the expression to be checked.
      Throws:
      AssertionError - if expression is true.
    • nonNull

      public static <T> T nonNull(@Nullable T value)
      Asserts given value is not null.
      Type Parameters:
      T - the type of the value.
      Parameters:
      value - the value to be checked.
      Returns:
      the value if it is not null.
      Throws:
      AssertionError - if the value is null.
      See Also: