Class CheckerSupplier<T>
java.lang.Object
com.luchersol.core.util.AbstractChecker<Supplier<T>,CheckerSupplier<T>>
com.luchersol.core.specialized_checkers.lambda.CheckerSupplier<T>
- Type Parameters:
T- the type of the result returned by theSupplier
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Supplier<T>,CheckerSupplier<T>>, Supplier<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:
-
Field Summary
Fields inherited from class com.luchersol.core.util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCheckerSupplier(Supplier<T> supplier, String name) Constructs a newCheckerSupplierwith the specified supplier and name. -
Method Summary
Modifier and TypeMethodDescriptionAsserts that calling theget()method of theSupplierdoes not throw any exception.static <T> CheckerSupplier<T> Creates a newCheckerSupplierfor the givenSupplierinstance with a default name.static <T> CheckerSupplier<T> Creates a newCheckerSupplierfor the givenSupplierinstance with a custom name.producesExpected(T expected) Asserts that theget()method of theSupplierproduces the expected result.Asserts that theget()method of theSupplierproduces a non-null result.protected CheckerSupplier<T> self()Returns this checker instance (for fluent API usage).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
-
CheckerSupplier
-
-
Method Details
-
check
Creates a newCheckerSupplierfor the givenSupplierinstance with a custom name.- Type Parameters:
T- the type of results supplied by theSupplier- Parameters:
supplier- theSupplierinstance to be checkedname- the name to identify this checker instance (useful for error messages)- Returns:
- a new
CheckerSupplierfor the providedSupplier
-
check
Creates a newCheckerSupplierfor the givenSupplierinstance with a default name.- Type Parameters:
T- the type of results supplied by theSupplier- Parameters:
supplier- theSupplierinstance to be checked- Returns:
- a new
CheckerSupplierfor the providedSupplier
-
self
Returns this checker instance (for fluent API usage).- Specified by:
selfin classAbstractChecker<Supplier<T>,CheckerSupplier<T>> - Returns:
- this
CheckerSupplierinstance
-
applyWithoutException
Asserts that calling theget()method of theSupplierdoes not throw any exception.- Returns:
- this
CheckerSupplierinstance for further validation
-
producesExpected
Asserts that theget()method of theSupplierproduces the expected result.- Parameters:
expected- the expected result to compare with the actual result ofget()- Returns:
- this
CheckerSupplierinstance for further validation
-
producesNonNull
Asserts that theget()method of theSupplierproduces a non-null result.- Returns:
- this
CheckerSupplierinstance for further validation
-