Skip to content

Commit

Permalink
Изменение интерфейса Predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloogefest committed Dec 11, 2024
1 parent 9fc0a75 commit 3e35134
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ public interface Predicate<T, F extends Throwable> {
@Contract("? -> ?")
boolean evaluate(final @Nullable T object) throws ValidationFault, F;

/**
* Создаёт предикат (1) объектов с методом {@linkplain #evaluate(Object)}, получающим от метода
* {@linkplain #evaluate(Object) this.evaluate(Object)} оценку и возвращающим её инверсию.
*
* @return [1].
*
* @since 1.0.0-RC1
*/
@Contract("-> new")
default @NonNull Predicate<T, F> not() {
return object -> !evaluate(object);
}

/**
* Создаёт предикат (2) объектов с методом {@linkplain #evaluate(Object)}, получающим от методов
* {@linkplain #evaluate(Object) this.evaluate(Object)} и {@linkplain #evaluate(Object) predicate.evaluate(Object)}
Expand All @@ -76,8 +89,8 @@ public interface Predicate<T, F extends Throwable> {
* @since 1.0.0-RC1
*/
@Contract("!null -> new; null -> fault")
default @Nullable Predicate<T, F> and(final @NonNull Predicate<? super T, ? extends F> predicate) throws
ValidationFault {
default @NonNull Predicate<T, F> and(final @NonNull Predicate<? super T, ? extends F> predicate) throws
ValidationFault {
Validator.nonNull(predicate, "The passed predicate");
return object -> evaluate(object) && predicate.evaluate(object);
}
Expand All @@ -95,8 +108,8 @@ public interface Predicate<T, F extends Throwable> {
* @since 1.0.0-RC1
*/
@Contract("!null -> new; null -> fault")
default @Nullable Predicate<T, F> or(final @NonNull Predicate<? super T, ? extends F> predicate) throws
ValidationFault {
default @NonNull Predicate<T, F> or(final @NonNull Predicate<? super T, ? extends F> predicate) throws
ValidationFault {
Validator.nonNull(predicate, "The passed predicate");
return object -> evaluate(object) || predicate.evaluate(object);
}
Expand All @@ -114,8 +127,8 @@ public interface Predicate<T, F extends Throwable> {
* @since 1.0.0-RC1
*/
@Contract("!null -> new; null -> fault")
default @Nullable Predicate<T, F> xor(final @NonNull Predicate<? super T, ? extends F> predicate) throws
ValidationFault {
default @NonNull Predicate<T, F> xor(final @NonNull Predicate<? super T, ? extends F> predicate) throws
ValidationFault {
Validator.nonNull(predicate, "The passed predicate");
return object -> evaluate(object) ^ predicate.evaluate(object);
}
Expand Down

0 comments on commit 3e35134

Please sign in to comment.