net.serenitybdd.screenplay.questions.NamedPredicate Maven / Gradle / Ivy
package net.serenitybdd.screenplay.questions;
import java.util.function.Predicate;
public class NamedPredicate implements Predicate{
private final String name;
private final Predicate predicate;
public NamedPredicate(String name, Predicate predicate) {
this.name = name;
this.predicate = predicate;
}
public String getName() {
return name;
}
public Predicate getPredicate() {
return predicate;
}
@Override
public String toString() {
return name;
}
@Override
public boolean test(T test) {
return predicate.test(test);
}
@Override
public Predicate and(Predicate super T> other) {
return new NamedPredicate(name, predicate.and(other));
}
@Override
public Predicate negate() {
return new NamedPredicate(name, predicate.negate());
}
@Override
public Predicate or(Predicate super T> other) {
return new NamedPredicate(name, predicate.or(other));
}
}