Class TaskIterator

java.lang.Object
org.cytoscape.work.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.

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.

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>
  • 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.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(Task task)
    Adds the given task to the end of this iterator.
    void
    append(TaskIterator taskIterator)
    Adds the tasks in the given TaskIterator to the end of this iterator.
    int
    Returns the current total number of tasks in the iterator.
    boolean
    Returns true if a call to next() would return another Task, otherwise false.
    void
    insertTasksAfter(Task referenceTask, Task... newTasks)
    Inserts "newTasks" immediately after "referenceTask".
    void
    insertTasksAfter(Task referenceTask, TaskIterator newTasks)
    Inserts "newTasks" immediately after "referenceTask".
    Returns the next Task in order if the TaskIterator can still yield more Tasks, otherwise throws an exception.
    void
    Unsupported -> always throws an exception!

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining
  • Constructor Details

    • 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 Details

    • 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.
    • remove

      public void remove()
      Unsupported -> always throws an exception!
      Specified by:
      remove in interface Iterator<Task>
      Throws:
      UnsupportedOperationException
    • 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