All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.screenplay.questions.NamedPredicate Maven / Gradle / Ivy

There is a newer version: 4.2.9
Show newest version
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 other) {
        return new NamedPredicate(name, predicate.and(other));
    }

    @Override
    public Predicate negate() {
        return new NamedPredicate(name, predicate.negate());
    }

    @Override
    public Predicate or(Predicate other) {
        return new NamedPredicate(name, predicate.or(other));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy