Interface PersistTaskIterable<A,T>
- All Superinterfaces:
PersistTask<A,
Iterable<T>>
- All Known Subinterfaces:
RetryablePersistTaskIterable<A,
T>
- All Known Implementing Classes:
AbstractGetNodesArgumentTask
,ExpandedTask
,GetNodesArgumentTask
,GetRecursiveNodesArgumentTask
,PartitionedTask
,QueryTask
A task that returns an iterable. This class defines combinator methods that only
make sense for iterables.
-
Method Summary
Modifier and TypeMethodDescriptiondefault PersistTaskIterable
<A, T> filter
(PersistTask<T, Boolean> predicate) Creates a new task that will execute this task and filters the resulting list by applying the givenpredicate
task.default PersistTask
<A, T> find
(PersistTask<T, Boolean> predicate) Return the first element of the result of this that fulfills the given predicate.default <V> PersistTaskIterable
<A, V> flatMap
(PersistTask<T, Iterable<V>> task) Creates a composed task which applies the given task to each element of the result of this task and returns a concatenation of the resulting list of lists.default <V> PersistTaskIterable
<A, T> forEach
(PersistTask<T, V> task) usesmap(PersistTask)
to run the given task for each element, but ignores the result and returns the original task as isdefault PersistTask
<A, T> get
(int index) Return the `index`-th element from the resulting list.default PersistTask
<A, T> Return the `index`-th element from the resulting list.default PersistTask
<A, T> default PersistTask
<A, T> Return the first element or throw an exception if there is more than one element or no element.default PersistTask
<A, T> getOnlyElement
(T defaultValue) Return the first element or the default value if the list is empty.default PersistTask
<A, T> getOnlyElement
(T defaultValue, boolean useDefault) static <A> PersistTaskIterable
<A, A> identity()
Create a task that always returns its argument wrapped in an iterable.default <V> PersistTaskIterable
<A, V> map
(PersistTask<T, V> task) Creates a composed task which applies the given task to each element of the result of this task and returns a list of all results.static <A,
B> PersistTaskIterable <A, B> Create a task that returns the given list on each run.Methods inherited from interface ch.tocco.nice2.persist.core.api.exec.PersistTask
andThenDo, compose, compose2, composeWhen, discardResult, expand, expand, getDescription, ifElse, orWhen, orWhenNot, passWhen, passWhenNot, run, skipErrors, unwrap
-
Method Details
-
of
Create a task that returns the given list on each run. -
identity
Create a task that always returns its argument wrapped in an iterable. Null values are mapped to an empty iterable. -
map
Creates a composed task which applies the given task to each element of the result of this task and returns a list of all results. This is the same as ```java asIterableTask(this.compose(task.expand(...))) ``` The returned task will never return null. If the listTask did not return a value or the entity list is empty an empty list is returned. -
forEach
usesmap(PersistTask)
to run the given task for each element, but ignores the result and returns the original task as is -
flatMap
Creates a composed task which applies the given task to each element of the result of this task and returns a concatenation of the resulting list of lists. -
filter
Creates a new task that will execute this task and filters the resulting list by applying the givenpredicate
task. Note, that the samepredicate
task is applied to each element, thus it must be stateless! -
find
Return the first element of the result of this that fulfills the given predicate. Apply the predicate to all element of the result of this until an element makes the predicate evaluate to `true`. This element is then returned. The predicate is not applied to subsequent elements. If the predicate returns `null`, it is treated as `false`. -
get
-
get
Return the `index`-th element from the resulting list. An exception is thrown if the index is out of range. -
get
Return the `index`-th element from the resulting list. If the index is out of bounds, return the default value. -
getOnlyElement
-
getOnlyElement
Return the first element or throw an exception if there is more than one element or no element. -
getOnlyElement
Return the first element or the default value if the list is empty. Throw an exception if there is more than one element.
-