Class CancelHandlingIterator<T>
java.lang.Object
ch.tocco.nice2.rest.action.spi.tasks.CancelHandlingIterator<T>
- All Implemented Interfaces:
Iterator<CancelHandlingIterator.Indexed<T>>
public class CancelHandlingIterator<T>
extends Object
implements Iterator<CancelHandlingIterator.Indexed<T>>
can be used to loop through some iterable until the task is cancelled or the end is reached
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()next()static <T> Iterable<T> withCancelHandling(Iterable<T> values, TaskContext taskContext) static <T> Iterable<CancelHandlingIterator.Indexed<T>> withIndexedCancelHandling(Iterable<T> values, TaskContext taskContext) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Method Details
-
withCancelHandling
- Type Parameters:
T- the type of the values you loop over- Parameters:
values- the original iterabletaskContext- the task context to check for cancellation- Returns:
- a new iterable that loops until cancelled or the end is reached
-
withIndexedCancelHandling
public static <T> Iterable<CancelHandlingIterator.Indexed<T>> withIndexedCancelHandling(Iterable<T> values, TaskContext taskContext) - Type Parameters:
T- the type of the values you loop over- Parameters:
values- the original iterabletaskContext- the task context to check for cancellation- Returns:
- a new iterable, combining values with their index, that loops until cancelled or the end is reached
-
hasNext
public boolean hasNext() -
next
-