Skip to content

Commit

Permalink
Введение метода Predicate::imply(Predicate)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloogefest committed Dec 11, 2024
1 parent 67b0566 commit ed09a9f
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,23 @@ public interface Predicate<T, F extends Throwable> {
return object -> evaluate(object) ^ predicate.evaluate(object);
}

/**
* Создаёт предикат (2) объектов с методом {@linkplain #evaluate(Object)}, получающим от методов
* {@linkplain #evaluate(Object) this.evaluate(Object)} и {@linkplain #evaluate(Object) predicate.evaluate(Object)}
* оценки и возвращающим их импликацию.
*
* @param predicate предикат (1) объектов.
*
* @return [2].
*
* @throws ValidationFault неудачная валидация [1].
* @since 1.0.0-RC1
*/
@Contract("!null -> new; null -> fault")
default @NonNull Predicate<T, F> imply(final @NonNull Predicate<? super T, ? extends F> predicate) throws
ValidationFault {
Validator.nonNull(predicate, "The passed predicate");
return object -> !evaluate(object) || predicate.evaluate(object);
}

}

0 comments on commit ed09a9f

Please sign in to comment.