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 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 util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CheckerBiFunction
(BiFunction<T, U, R> function, String name) Constructs a newCheckerBiFunction
with the specifiedBiFunction
and 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 util.AbstractChecker
checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, show, showNotThrownException, showThrownException, stop
-
Constructor Details
-
CheckerBiFunction
Constructs a newCheckerBiFunction
with the specifiedBiFunction
and name.- Parameters:
function
- theBiFunction
to 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 theBiFunction
being checkedU
- the type of the second input to theBiFunction
being 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 theBiFunction
being checkedU
- the type of the second input to theBiFunction
being 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:
self
in 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
-