Class CheckerBiFunction<T,U,R>
java.lang.Object
com.luchersol.core.util.AbstractChecker<BiFunction<T,U,R>,CheckerBiFunction<T,U,R>>
com.luchersol.core.specialized_checkers.lambda.CheckerBiFunction<T,U,R>
- Type Parameters:
T- the type of the first argument to the functionU- the type of the second argument to the functionR- 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:
-
Field Summary
Fields inherited from class com.luchersol.core.util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCheckerBiFunction(BiFunction<T, U, R> function, String name) Constructs a newCheckerBiFunctionwith the specifiedBiFunctionand name. -
Method Summary
Modifier and TypeMethodDescriptionActivates deep cloning of inputs before passing them to the BiFunction.applyWithoutException(T input1, U input2) Checks that the BiFunction can be applied to the given inputs without throwing an exception.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.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.Deactivates deep cloning of inputs before passing them to the BiFunction.producesExpected(T input1, U input2, R expected) Checks that the BiFunction produces the expected result for the given inputs.producesNonNull(T input1, U input2) Checks that the BiFunction produces a non-null result for the given inputs.protected CheckerBiFunction<T, U, R> self()Returns this instance (for fluent API).Methods inherited from class com.luchersol.core.util.AbstractChecker
checkProperty, checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, setBackObject, setExceptionTracker, setName, setObject, setSaveErrors, setStop, show, showPassedChecks, showThrownException, stop, toChecker, updateChecker
-
Constructor Details
-
CheckerBiFunction
Constructs a newCheckerBiFunctionwith the specifiedBiFunctionand name.- Parameters:
function- theBiFunctionto be wrapped and checkedname- the name identifying this checker function
-
-
Method Details
-
check
Creates a CheckerBiFunction for the given BiFunction and assigns a custom name.- Type Parameters:
T- the type of the first input to theBiFunctionbeing checkedU- the type of the second input to theBiFunctionbeing checkedR- the type of the result returned by theBiFunction- Parameters:
bifunction- the BiFunction to checkname- the name to assign to this checker- Returns:
- a CheckerBiFunction instance for the given BiFunction
-
check
Creates a CheckerBiFunction for the given BiFunction with a default name.- Type Parameters:
T- the type of the first input to theBiFunctionbeing checkedU- the type of the second input to theBiFunctionbeing checkedR- the type of the result returned by theBiFunction- Parameters:
bifunction- the BiFunction to check- Returns:
- a CheckerBiFunction instance for the given BiFunction
-
self
Returns this instance (for fluent API).- Specified by:
selfin classAbstractChecker<BiFunction<T,U, R>, CheckerBiFunction<T, U, R>> - Returns:
- this CheckerBiFunction instance
-
activateDeepClone
Activates deep cloning of inputs before passing them to the BiFunction.- Returns:
- this CheckerBiFunction instance
-
deactivateDeepClone
Deactivates deep cloning of inputs before passing them to the BiFunction.- Returns:
- this CheckerBiFunction instance
-
applyWithoutException
-
producesExpected
Checks that the BiFunction produces the expected result for the given inputs.- Parameters:
input1- the first input valueinput2- the second input valueexpected- the expected result- Returns:
- this CheckerBiFunction instance
-
producesNonNull
-