// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/CompositeWebTask.java
// public class CompositeWebTask extends BaseWebTask implements Iterable<WebTask> {
// 
// 	private List<WebTask> subtasks = new ArrayList<>();
// 	
// 	/**
// 	 * @see #CompositeWebTask(List)
// 	 */
// 	public CompositeWebTask(WebTask... subtasks) {
// 		this(Arrays.asList(subtasks));
// 	}
// 
// 	/**
// 	 * Set the given list as the list of components of this composite.
//      * Replace any null subtask with a {@link WebTasks#nullTask()}.
// 	 */
// 	public CompositeWebTask(List<WebTask> subtasks) {
// 		super();
// 		Collections.replaceAll(subtasks, null, WebTasks.nullTask());
// 		this.subtasks.addAll(subtasks);
// 	}
// 
// 	/**
// 	 * Runs each subtask in order, and finally return the
// 	 * page that the last task was visiting.
// 	 * Each subtask will run with the same user as the composite.
// 	 * 
// 	 * @throws IllegalStateException if the user set in this composite is null
// 	 */
// 	@Override
// 	public WebPage run(WebPage initialPage) {
// 		if(getUser() == null)
// 			throw new IllegalStateException("the user set is null");
// 		WebPage currentPage = initialPage;
// 		for(WebTask task : this) {
// 			logger.info("BEGIN subtask " + task.getClass().getSimpleName());
// 			// before running the subtask, set the user
// 			task.setUser(getUser());
// 			currentPage = task.run(currentPage);
// 			logger.info("END subtask " + task.getClass().getSimpleName());
// 		}
// 		return currentPage;
// 	}
// 
// 	/**
// 	 * The iterator for iterating over the subtasks
// 	 * this composite is made up of.
// 	 * <p>
// 	 * Backed by {@link List#iterator()}.
// 	 */
// 	@Override
// 	public Iterator<WebTask> iterator() {
// 		return subtasks.iterator();
// 	}
// 	
// 	/**
// 	 * Append the given subtasks to the list of components. 
// 	 * @param subtasks
// 	 * @return this
// 	 */
// 	public CompositeWebTask append(WebTask... subtasks) {
// 		this.subtasks.addAll(Arrays.asList(subtasks));
// 		return this;
// 	}
// 
// }
// 
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java
// public interface WebTask {
// 
// 	/**
// 	 * Perform this task as the user {@link #getUser()}.
// 	 * Precondition: the user must have already been set
// 	 * (see {@link #setUser(WebUser)}).
// 	 * 
// 	 * @param initialPage the page it is displayed before this task starts
// 	 * @return the last page that is displayed after this task finishes
// 	 */
// 	public WebPage run(WebPage initialPage);
// 	
// 	/**
// 	 * Builds an {@link OrWebTask} made up of (in order)
// 	 * this task and the given alternative task.
// 	 * This method can be "recursively" chained in order to define
// 	 * a multi-member OR, e.g.:
// 	 * <pre>
// 	 * {@code
// 	 * new MyTask()
// 	 *    .or(new AlternativeTask1())
// 	 *    .or(new AlternativeTask2())
// 	 *    .or(new AlternativeTask3())
// 	 * ;
// 	 * }
// 	 * </pre>
// 	 * 
// 	 * @param alternativeTask the task to run if this task fails
// 	 * @return an {@link OrWebTask} made up of (in order)
// 	 *         this task and the alternative
// 	 */
// 	default public OrWebTask or(WebTask alternativeTask) {
// 		return new OrWebTask(this, alternativeTask);
// 	}
// 	
// 	/**
// 	 * @param user the user this task will run as.
// 	 * @return this
// 	 */
// 	public WebTask setUser(WebUser user);
// 
// 	/**
// 	 * @return the user that this task runs as
// 	 */
// 	public WebUser getUser();
// 	
// }
// 
// Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java
// public interface WebPage {
// 
// 	/**
// 	 * @see Config#getBaseUrl()
// 	 */
// 	public final static String BASE_URL = Config.getBaseUrl();
// 	
// 
// 	/**
// 	 * @see WebDriver#getTitle()
// 	 */
// 	public String getTitle();
// 
// 	/**
// 	 * @see WebDriver#getCurrentUrl()
// 	 */
// 	public String getCurrentUrl();
// 
// }


import com.google.inject.Inject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import me.alb_i986.selenium.tinafw.tasks.CompositeWebTask;
import me.alb_i986.selenium.tinafw.tasks.WebTask;
import me.alb_i986.selenium.tinafw.ui.WebPage;
	 * (which is part of the state of this object).
	 * Finally update the current page with the one
	 * the given task visited last.
	 * 
	 * @param task
	 * @return this
	 * 
	 * @see WebTask#run(WebPage)
	 */
	@SuppressWarnings("unchecked")
	public T doTask(WebTask task) {
		task.setUser(this);
		this.currentPage = task.run(currentPage);
		return (T) this;
	}

	/**
	 * Instantiate a {@link CompositeWebTask} made up of all
	 * of the given tasks, and run it.
	 * <p>
	 * Convenience method for running multiple tasks at once
	 * without wrapping them around a {@link CompositeWebTask}
	 * by hand.
	 * 
	 * @param tasks
	 * @return this
	 * 
	 * @see #doTask(WebTask)
	 */
	public T doTasks(WebTask... tasks) {
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/CompositeWebTask.java
// public class CompositeWebTask extends BaseWebTask implements Iterable<WebTask> {
// 
// 	private List<WebTask> subtasks = new ArrayList<>();
// 	
// 	/**
// 	 * @see #CompositeWebTask(List)
// 	 */
// 	public CompositeWebTask(WebTask... subtasks) {
// 		this(Arrays.asList(subtasks));
// 	}
// 
// 	/**
// 	 * Set the given list as the list of components of this composite.
//      * Replace any null subtask with a {@link WebTasks#nullTask()}.
// 	 */
// 	public CompositeWebTask(List<WebTask> subtasks) {
// 		super();
// 		Collections.replaceAll(subtasks, null, WebTasks.nullTask());
// 		this.subtasks.addAll(subtasks);
// 	}
// 
// 	/**
// 	 * Runs each subtask in order, and finally return the
// 	 * page that the last task was visiting.
// 	 * Each subtask will run with the same user as the composite.
// 	 * 
// 	 * @throws IllegalStateException if the user set in this composite is null
// 	 */
// 	@Override
// 	public WebPage run(WebPage initialPage) {
// 		if(getUser() == null)
// 			throw new IllegalStateException("the user set is null");
// 		WebPage currentPage = initialPage;
// 		for(WebTask task : this) {
// 			logger.info("BEGIN subtask " + task.getClass().getSimpleName());
// 			// before running the subtask, set the user
// 			task.setUser(getUser());
// 			currentPage = task.run(currentPage);
// 			logger.info("END subtask " + task.getClass().getSimpleName());
// 		}
// 		return currentPage;
// 	}
// 
// 	/**
// 	 * The iterator for iterating over the subtasks
// 	 * this composite is made up of.
// 	 * <p>
// 	 * Backed by {@link List#iterator()}.
// 	 */
// 	@Override
// 	public Iterator<WebTask> iterator() {
// 		return subtasks.iterator();
// 	}
// 	
// 	/**
// 	 * Append the given subtasks to the list of components. 
// 	 * @param subtasks
// 	 * @return this
// 	 */
// 	public CompositeWebTask append(WebTask... subtasks) {
// 		this.subtasks.addAll(Arrays.asList(subtasks));
// 		return this;
// 	}
// 
// }
// 
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java
// public interface WebTask {
// 
// 	/**
// 	 * Perform this task as the user {@link #getUser()}.
// 	 * Precondition: the user must have already been set
// 	 * (see {@link #setUser(WebUser)}).
// 	 * 
// 	 * @param initialPage the page it is displayed before this task starts
// 	 * @return the last page that is displayed after this task finishes
// 	 */
// 	public WebPage run(WebPage initialPage);
// 	
// 	/**
// 	 * Builds an {@link OrWebTask} made up of (in order)
// 	 * this task and the given alternative task.
// 	 * This method can be "recursively" chained in order to define
// 	 * a multi-member OR, e.g.:
// 	 * <pre>
// 	 * {@code
// 	 * new MyTask()
// 	 *    .or(new AlternativeTask1())
// 	 *    .or(new AlternativeTask2())
// 	 *    .or(new AlternativeTask3())
// 	 * ;
// 	 * }
// 	 * </pre>
// 	 * 
// 	 * @param alternativeTask the task to run if this task fails
// 	 * @return an {@link OrWebTask} made up of (in order)
// 	 *         this task and the alternative
// 	 */
// 	default public OrWebTask or(WebTask alternativeTask) {
// 		return new OrWebTask(this, alternativeTask);
// 	}
// 	
// 	/**
// 	 * @param user the user this task will run as.
// 	 * @return this
// 	 */
// 	public WebTask setUser(WebUser user);
// 
// 	/**
// 	 * @return the user that this task runs as
// 	 */
// 	public WebUser getUser();
// 	
// }
// 
// Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java
// public interface WebPage {
// 
// 	/**
// 	 * @see Config#getBaseUrl()
// 	 */
// 	public final static String BASE_URL = Config.getBaseUrl();
// 	
// 
// 	/**
// 	 * @see WebDriver#getTitle()
// 	 */
// 	public String getTitle();
// 
// 	/**
// 	 * @see WebDriver#getCurrentUrl()
// 	 */
// 	public String getCurrentUrl();
// 
// }


// Path: src/main/java/me/alb_i986/selenium/tinafw/domain/WebUser.java
import com.google.inject.Inject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import me.alb_i986.selenium.tinafw.tasks.CompositeWebTask;
import me.alb_i986.selenium.tinafw.tasks.WebTask;
import me.alb_i986.selenium.tinafw.ui.WebPage;

	 * (which is part of the state of this object).
	 * Finally update the current page with the one
	 * the given task visited last.
	 * 
	 * @param task
	 * @return this
	 * 
	 * @see WebTask#run(WebPage)
	 */
	@SuppressWarnings("unchecked")
	public T doTask(WebTask task) {
		task.setUser(this);
		this.currentPage = task.run(currentPage);
		return (T) this;
	}

	/**
	 * Instantiate a {@link CompositeWebTask} made up of all
	 * of the given tasks, and run it.
	 * <p>
	 * Convenience method for running multiple tasks at once
	 * without wrapping them around a {@link CompositeWebTask}
	 * by hand.
	 * 
	 * @param tasks
	 * @return this
	 * 
	 * @see #doTask(WebTask)
	 */
	public T doTasks(WebTask... tasks) {
		return doTask(new CompositeWebTask(tasks));