Class CheckerSupplier<T>

java.lang.Object
util.AbstractChecker<Supplier<T>,CheckerSupplier<T>>
specialized_checkers.lambda.CheckerSupplier<T>
Type Parameters:
T - the type of the result returned by the Supplier
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Supplier<T>,CheckerSupplier<T>>,Supplier<T>>

public class CheckerSupplier<T> extends AbstractChecker<Supplier<T>,CheckerSupplier<T>>
A specialized checker for Supplier instances, providing a fluent API for validating function behavior and results. This class allows assertions such as verifying that a function does not throw exceptions, produces expected results, or returns non-null values for given inputs.

Example usage:

     CheckerSupplier<Integer> checker = CheckerSupplier.check(() -> 5)
            .applyWithoutException()
            .producesExpected(5)
            .producesNonNull();
 
See Also:
  • Constructor Details

    • CheckerSupplier

      protected CheckerSupplier(Supplier<T> supplier, String name)
      Constructs a new CheckerSupplier with the specified supplier and name.
      Parameters:
      supplier - the Supplier to be used by this checker
      name - the name identifying this checker
  • Method Details

    • check

      public static <T> CheckerSupplier<T> check(Supplier<T> supplier, String name)
      Creates a new CheckerSupplier for the given Supplier instance with a custom name.
      Type Parameters:
      T - the type of results supplied by the Supplier
      Parameters:
      supplier - the Supplier instance to be checked
      name - the name to identify this checker instance (useful for error messages)
      Returns:
      a new CheckerSupplier for the provided Supplier
    • check

      public static <T> CheckerSupplier<T> check(Supplier<T> supplier)
      Creates a new CheckerSupplier for the given Supplier instance with a default name.
      Type Parameters:
      T - the type of results supplied by the Supplier
      Parameters:
      supplier - the Supplier instance to be checked
      Returns:
      a new CheckerSupplier for the provided Supplier
    • self

      protected CheckerSupplier<T> self()
      Returns this checker instance (for fluent API usage).
      Specified by:
      self in class AbstractChecker<Supplier<T>,CheckerSupplier<T>>
      Returns:
      this CheckerSupplier instance
    • applyWithoutException

      public CheckerSupplier<T> applyWithoutException()
      Asserts that calling the get() method of the Supplier does not throw any exception.
      Returns:
      this CheckerSupplier instance for further validation
    • producesExpected

      public CheckerSupplier<T> producesExpected(T expected)
      Asserts that the get() method of the Supplier produces the expected result.
      Parameters:
      expected - the expected result to compare with the actual result of get()
      Returns:
      this CheckerSupplier instance for further validation
    • producesNonNull

      public CheckerSupplier<T> producesNonNull()
      Asserts that the get() method of the Supplier produces a non-null result.
      Returns:
      this CheckerSupplier instance for further validation