Class CheckerBiFunction<T,U,R>

java.lang.Object
util.AbstractChecker<BiFunction<T,U,R>,CheckerBiFunction<T,U,R>>
specialized_checkers.lambda.CheckerBiFunction<T,U,R>
Type Parameters:
T - the type of the first argument to the function
U - the type of the second argument to the function
R - the type of the result of the function
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<BiFunction<T,U,R>,CheckerBiFunction<T,U,R>>,BiFunction<T,U,R>>

public class CheckerBiFunction<T,U,R> extends AbstractChecker<BiFunction<T,U,R>,CheckerBiFunction<T,U,R>>
A specialized checker for BiFunction instances, providing a fluent API for validating the behavior of a BiFunction<T, U, R>. This class allows you to assert that a given BiFunction can be applied without throwing exceptions, produces expected results, or returns non-null values for specific inputs. It also supports optional deep cloning of input arguments before passing them to the function, to ensure immutability or test side effects.

Example usage:

     CheckerBiFunction<String, Integer, String> checker =
         CheckerBiFunction.check((s, i) -> s.repeat(i))
             .activateDeepClone()
             .applyWithoutException("abc", 2)
             .producesExpected("abc", 2, "abcabc")
             .producesNonNull("abc", 2);
 
See Also:
  • Constructor Details

    • CheckerBiFunction

      protected CheckerBiFunction(BiFunction<T,U,R> function, String name)
      Constructs a new CheckerBiFunction with the specified BiFunction and name.
      Parameters:
      function - the BiFunction to be wrapped and checked
      name - the name identifying this checker function
  • Method Details

    • check

      public static <T, U, R> CheckerBiFunction<T,U,R> check(BiFunction<T,U,R> bifunction, String name)
      Creates a CheckerBiFunction for the given BiFunction and assigns a custom name.
      Type Parameters:
      T - the type of the first input to the BiFunction being checked
      U - the type of the second input to the BiFunction being checked
      R - the type of the result returned by the BiFunction
      Parameters:
      bifunction - the BiFunction to check
      name - the name to assign to this checker
      Returns:
      a CheckerBiFunction instance for the given BiFunction
    • check

      public static <T, U, R> CheckerBiFunction<T,U,R> check(BiFunction<T,U,R> bifunction)
      Creates a CheckerBiFunction for the given BiFunction with a default name.
      Type Parameters:
      T - the type of the first input to the BiFunction being checked
      U - the type of the second input to the BiFunction being checked
      R - the type of the result returned by the BiFunction
      Parameters:
      bifunction - the BiFunction to check
      Returns:
      a CheckerBiFunction instance for the given BiFunction
    • self

      protected CheckerBiFunction<T,U,R> self()
      Returns this instance (for fluent API).
      Specified by:
      self in class AbstractChecker<BiFunction<T,U,R>,CheckerBiFunction<T,U,R>>
      Returns:
      this CheckerBiFunction instance
    • activateDeepClone

      public CheckerBiFunction<T,U,R> activateDeepClone()
      Activates deep cloning of inputs before passing them to the BiFunction.
      Returns:
      this CheckerBiFunction instance
    • deactivateDeepClone

      public CheckerBiFunction<T,U,R> deactivateDeepClone()
      Deactivates deep cloning of inputs before passing them to the BiFunction.
      Returns:
      this CheckerBiFunction instance
    • applyWithoutException

      public CheckerBiFunction<T,U,R> applyWithoutException(T input1, U input2)
      Checks that the BiFunction can be applied to the given inputs without throwing an exception.
      Parameters:
      input1 - the first input value
      input2 - the second input value
      Returns:
      this CheckerBiFunction instance
    • producesExpected

      public CheckerBiFunction<T,U,R> producesExpected(T input1, U input2, R expected)
      Checks that the BiFunction produces the expected result for the given inputs.
      Parameters:
      input1 - the first input value
      input2 - the second input value
      expected - the expected result
      Returns:
      this CheckerBiFunction instance
    • producesNonNull

      public CheckerBiFunction<T,U,R> producesNonNull(T input1, U input2)
      Checks that the BiFunction produces a non-null result for the given inputs.
      Parameters:
      input1 - the first input value
      input2 - the second input value
      Returns:
      this CheckerBiFunction instance