Skip to content

Commit

Permalink
Constraint shouldn't implement Predicate.
Browse files Browse the repository at this point in the history
  • Loading branch information
vardlokkur committed Dec 14, 2015
1 parent eecbbe4 commit 0659bde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/main/java/pl/ais/commons/bean/validation/Constraint.java
Expand Up @@ -7,7 +7,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.function.BiFunction;
import java.util.function.Predicate;

/**
* Defines the API contract for the Constraint.
Expand All @@ -17,7 +16,7 @@
* @author Warlock, AIS.PL
* @since 1.2.1
*/
public interface Constraint<C extends Constraint<C, T>, T> extends BiFunction<Constrainable<? extends T>, ValidationListener, Boolean>, Predicate<T> {
public interface Constraint<C extends Constraint<C, T>, T> extends BiFunction<Constrainable<? extends T>, ValidationListener, Boolean> {

/**
* Verifies if given constrainable matches the constraint and reports violation if needed.
Expand Down Expand Up @@ -67,7 +66,6 @@ default Boolean apply(final Constrainable<? extends T> constrainable, final Vali
* @param candidate value to be matched against this constraint
* @return {@code true} if given argument matches this constraint, {@code false} otherwise
*/
@Override
boolean test(@Nullable T candidate);

/**
Expand Down
Expand Up @@ -46,7 +46,8 @@ public static <T> Constrainable<T> allOf(final T first, final T second, final T.
*/
@Override
public Boolean apply(final Constraint<?, ? super T> constraint) {
return elements.stream().allMatch(constraint);
return elements.stream()
.allMatch(constraint::test);
}

/**
Expand Down Expand Up @@ -82,7 +83,8 @@ public static <T> Constrainable<T> anyOf(final T first, final T second, final T.
*/
@Override
public Boolean apply(final Constraint<?, ? super T> constraint) {
return elements.stream().anyMatch(constraint);
return elements.stream()
.anyMatch(constraint::test);
}

/**
Expand Down

0 comments on commit 0659bde

Please sign in to comment.