![JAR search and dependency download from the Maven repository](/logo.png)
net.serenitybdd.screenplay.CompositePerformable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serenity-screenplay Show documentation
Show all versions of serenity-screenplay Show documentation
Support for the User Journey pattern in Serenity
package net.serenitybdd.screenplay;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CompositePerformable implements Performable {
private final List todoList;
private CompositePerformable(List todoList) {
this.todoList = todoList;
}
public static Performable from(Performable firstPerformable, Performable nextPerformable) {
List todoList = new ArrayList<>();
todoList.addAll(flattened(firstPerformable));
todoList.addAll(flattened(nextPerformable));
return new CompositePerformable(todoList);
}
@Override
public void performAs(T actor) {
todoList.forEach(actor::attemptsTo);
}
private static List flattened(Performable performable) {
if (performable instanceof CompositePerformable) {
return ((CompositePerformable) performable).todoList;
} else {
return Collections.singletonList(performable);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy