SupplierFactory
A factory for creating more complex Supplier objects, particularly useful for boolean conditions. This class is a more robust and recommended alternative to SupplierFilter (which is deprecated).
Methods
invert(Supplier<Boolean> supplier)
Returns a new Supplier<Boolean> that provides the logical inverse of the boolean value returned by the input supplier.
supplierFor(Supplier<T> supplier, Predicate<T> predicate)
Creates a Supplier<Boolean> that evaluates a predicate against the value provided by an input supplier.
<T>: The type of value supplied by the inputsupplier.supplier: TheSupplierthat provides the value to be tested.predicate: ThePredicatethat tests the supplied value.
fromDouble(Supplier<Double> supplier, double tolerance)
Creates a Supplier<Boolean> that returns true if the absolute value of the double supplied by the input supplier is greater than or equal to the specified tolerance.
fromDouble(Supplier<Double> supplier)
Creates a Supplier<Boolean> that returns true if the absolute value of the double supplied by the input supplier is greater than or equal to 0 (effectively checking if the value is non-zero).
invertAll(Collection<Supplier<Boolean>> collection)
Returns a new Collection of Supplier<Boolean> objects, where each supplier in the new collection provides the inverted boolean value of the corresponding supplier in the input collection.
invertAll(Supplier<Boolean>[] collection)
Returns a new List of Supplier<Boolean> objects, where each supplier in the new list provides the inverted boolean value of the corresponding supplier in the input array.
anyTrue(Supplier<Boolean>... suppliers)
Returns a Supplier<Boolean> that returns true if any of the provided boolean suppliers return true.
anyFalse(Supplier<Boolean>... suppliers)
Returns a Supplier<Boolean> that returns true if any of the provided boolean suppliers return false.
allTrue(Supplier<Boolean>... suppliers)
Returns a Supplier<Boolean> that returns true if all of the provided boolean suppliers return true.
allFalse(Supplier<Boolean>... suppliers)
Returns a Supplier<Boolean> that returns true if all of the provided boolean suppliers return false.
trueThenAllFalse(Supplier<Boolean> mustBeTrue, Supplier<Boolean>... suppliers)
Returns a Supplier<Boolean> that returns true if the mustBeTrue supplier returns true AND all of the other suppliers return false.
falseThenAllTrue(Supplier<Boolean> mustBeFalse, Supplier<Boolean>... suppliers)
Returns a Supplier<Boolean> that returns true if the mustBeFalse supplier returns false AND all of the other suppliers return true.