package com.twasyl.slideshowfx.utils.concurrent;
import javafx.concurrent.Task;
import java.util.ArrayList;
import java.util.List;
/**
* This class is used in the {@link com.twasyl.slideshowfx.utils.concurrent.TaskAction#forTask(javafx.concurrent.Task)}
* method. It identifies for which Task an action should be triggered when a {@link com.twasyl.slideshowfx.utils.concurrent.WhenPredicate}
* is defined.
*
* @author Thierry Wasylczenko
* @version 1.0.0
* @since SlideshowFX 1.0
*/
public class ForPredicate {
/**
* The list of all WhenPredicate generated by the {@link #when()} method.
*/
protected final List<WhenPredicate> when = new ArrayList<>();
/**
* The task associated to this predicate.
*/
protected Task task;
protected ForPredicate(final Task task) {
this.task = task;
}
/**
* Creates a {@link com.twasyl.slideshowfx.utils.concurrent.WhenPredicate} for the given task.
* @return a well created {@link com.twasyl.slideshowfx.utils.concurrent.WhenPredicate}.
*/
public WhenPredicate when() {
final WhenPredicate whenPredicate = new WhenPredicate(this);
this.when.add(whenPredicate);
return whenPredicate;
}
}