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

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

There is a newer version: 4.2.9
Show newest version
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> listQuestion;
    private final Comparator comparator;

    public SortedQuestion(Question> listQuestion) {
        this(listQuestion, null);
    }

    public SortedQuestion(Question> listQuestion, Comparator 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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy