Add another predicate and comparator.
ComparatorWithPredicateFactory
use the identical orIf method instead. add will be removed in a future release.
a predicate that indicates if the following comparator can handle the value
a comparator for the incoming value
Creates a single comparator that will only accept values, which both match one of the attached predicates.
ComparatorWithPredicateFactory
Creates a single comparator that will only accept values, which both match one of the attached predicates.
ComparatorWithPredicateFactory
Add another predicate and comparator.
ComparatorWithPredicateFactory
a predicate that indicates if the following comparator can handle the value
a comparator for the incoming value
Creates a single comparator that will only accept values, which both match one of the attached predicates.
ComparatorWithPredicateFactory
use the identical orElseThrow method instead. toComparator will be removed in a future release.
Generated using TypeDoc
A factory that holds a list of comparators and attached predicates. Use the
orIfmethod to push additional comparators with predicates, thus broadening the range of accepted values and types.orElseandorElseThrowwill produce the finalComparator, that will only accept values which match one of the added predicates. Predicates will be checked in the same order as they were added.On each comparator call both arguments must match the same predicate. If no such predicate exists, the comparator will either throw an error or use a fallback comparator, depending on whether you used
orElseThrowororElserespectively.Use type guards as predicates to ensure the best type safety.
Example