net.serenitybdd.screenplay.questions.SortedQuestion 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.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@Subject("the minimum value of #listQuestion")
public class SortedQuestion> implements Question> {
private final Question extends List> listQuestion;
private final Comparator super T> comparator;
public SortedQuestion(Question extends List> listQuestion) {
this(listQuestion, null);
}
public SortedQuestion(Question extends List> listQuestion, Comparator super T> comparator) {
this.listQuestion = listQuestion;
this.comparator = comparator;
}
@Override
public List answeredBy(Actor actor) {
List sortedItems = new ArrayList<>(listQuestion.answeredBy(actor));
Collections.sort(sortedItems, comparator);
return sortedItems;
}
}