net.serenitybdd.screenplay.questions.MaxQuestion Maven / Gradle / Ivy
package net.serenitybdd.screenplay.questions;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Question;
import net.serenitybdd.screenplay.annotations.Subject;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@Subject("the maximum value of #listQuestion")
public class MaxQuestion> implements Question {
private final Question extends Collection> listQuestion;
private final Comparator super T> comparator;
public MaxQuestion(Question extends Collection> listQuestion) {
this(listQuestion, null);
}
public MaxQuestion(Question extends Collection> listQuestion, Comparator super T> comparator) {
this.listQuestion = listQuestion;
this.comparator = comparator;
}
@Override
public T answeredBy(Actor actor) {
return Collections.max(listQuestion.answeredBy(actor), comparator);
}
}