Class TaskIterator

  • All Implemented Interfaces:
    Iterator<Task>

    public final class TaskIterator
    extends Object
    implements Iterator<Task>
    A TaskIterator provides the functionality of sequencing Tasks. Tasks provided by TaskIterator can be executed by calling a TaskManager's execute() method.

    Module: work-api

    To use this in your app, include the following dependency in your POM:

    <dependency>
        <groupId>org.cytoscape</groupId>
        <artifactId>work-api</artifactId>
    </dependency>

    Cytoscape Backwards Compatibility (Final Class): This class is final and therefore can't be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.
    • Constructor Summary

      Constructors 
      Constructor Description
      TaskIterator​(int expectedNumTasks, Task... initialTasks)
      Constructs an iterator that will yield Tasks in the order that they were passed into this constructor.
      TaskIterator​(Task... initialTasks)
      Constructs an iterator that will yield Tasks in the order that they were passed into this constructor.
    • Constructor Detail

      • TaskIterator

        public TaskIterator​(int expectedNumTasks,
                            Task... initialTasks)
        Constructs an iterator that will yield Tasks in the order that they were passed into this constructor.
        Parameters:
        expectedNumTasks - The total number of tasks that the initialTasks are likely to spawn.
        initialTasks - the Tasks to place into the iterator.
      • TaskIterator

        public TaskIterator​(Task... initialTasks)
        Constructs an iterator that will yield Tasks in the order that they were passed into this constructor.
        Parameters:
        initialTasks - the Tasks to place into the iterator.
    • Method Detail

      • insertTasksAfter

        public void insertTasksAfter​(Task referenceTask,
                                     Task... newTasks)
                              throws IllegalStateException
        Inserts "newTasks" immediately after "referenceTask".
        Parameters:
        referenceTask - task to insert newTasks after.
        newTasks - tasks to insert after referenceTask.
        Throws:
        IllegalStateException - if "referenceTask" is not known to the iterator.
      • insertTasksAfter

        public void insertTasksAfter​(Task referenceTask,
                                     TaskIterator newTasks)
                              throws IllegalStateException
        Inserts "newTasks" immediately after "referenceTask".
        Parameters:
        referenceTask - the Task to insert "newTasks" after.
        newTasks - the TaskIterator the tasks to insert.
        Throws:
        IllegalStateException - if "referenceTask" is not known to the iterator.
      • hasNext

        public boolean hasNext()
        Returns true if a call to next() would return another Task, otherwise false.
        Specified by:
        hasNext in interface Iterator<Task>
        Returns:
        true if a call to next() would return another Task, otherwise false.
      • next

        public Task next()
        Returns the next Task in order if the TaskIterator can still yield more Tasks, otherwise throws an exception.
        Specified by:
        next in interface Iterator<Task>
        Returns:
        the next Task in order if the TaskIterator can still yield more Tasks, otherwise throws an exception.
      • getNumTasks

        public int getNumTasks()
        Returns the current total number of tasks in the iterator. As tasks get added to the iterator, this number will change, so this should not be viewed as a fixed or final value!
        Returns:
        the current total number of tasks in the iterator.
      • append

        public void append​(Task task)
        Adds the given task to the end of this iterator.
        Parameters:
        task - task to insert
      • append

        public void append​(TaskIterator taskIterator)
        Adds the tasks in the given TaskIterator to the end of this iterator.
        Parameters:
        taskIterator - the tasks to insert