public class DoubleAsyncBuilder
extends java.lang.Object
public void processFiles(ObjectCollection<String> potentialFiles) {
potentialFiles.asAsync()
.map(Paths::get).filter(Files::exists) //Modifies the collection (Optional)
.forEach(Files::delete) //Creates the action (Required)
.onCompletion(T -> {}} //Callback on completion (Optional)
.execute() //Starts the task. (Required)
}
| Modifier and Type | Class and Description |
|---|---|
static class |
DoubleAsyncBuilder.BaseDoubleTask
Base Task of the Actions that can be performed.
|
| Constructor and Description |
|---|
DoubleAsyncBuilder(DoubleAsyncBuilder.BaseDoubleTask task)
Helper constructor.
|
DoubleAsyncBuilder(DoubleIterable iterable)
Main Constructor that uses a Iterable to build a Offthread Task.
|
| Modifier and Type | Method and Description |
|---|---|
<E> ObjectAsyncBuilder<E> |
arrayflatMap(DoubleFunction<E[]> mapper)
Maps the elements to something else
|
IntAsyncBuilder |
count(DoublePredicate filter)
Counts all desired elements inside the Iterable
|
DoubleAsyncBuilder |
distinct()
Removes duplicated elements out of the Iterable
|
DoubleTask |
execute()
Starts the Execution of the task without awaiting its result
|
DoubleAsyncBuilder |
executor(java.util.concurrent.Executor executor)
Optional way to add a custom executor that runs this offthread task.
|
DoubleAsyncBuilder |
filter(DoublePredicate filter)
Filters out the unwanted elements out of the Iterable
|
DoubleAsyncBuilder |
findFirst(DoublePredicate filter)
Searches through the elements of the Iterable to find if the desired element.
|
<E,V extends java.lang.Iterable<E>> |
flatMap(DoubleFunction<V> mapper)
Maps the elements to something else
|
ObjectAsyncBuilder<java.lang.Void> |
forEach(DoubleConsumer action)
Iterates over the Iterable with a desired action
|
double |
join()
Starts the Execution of the task and will await its completion, returning the result.
|
double |
join(long timeout,
java.util.concurrent.TimeUnit unit)
Starts the Execution of the task and will await its completion with a timeout, returning the result.
|
DoubleAsyncBuilder |
limit(long limit)
Limits how many elements are inside of the Iterable
|
<E> ObjectAsyncBuilder<E> |
map(DoubleFunction<E> mapper)
Maps the elements to something else
|
BooleanAsyncBuilder |
matchAll(DoublePredicate filter)
Searches through the elements of the Iterable to find if all the desired elements are present.
|
BooleanAsyncBuilder |
matchAny(DoublePredicate filter)
Searches through the elements of the Iterable to find if the desired element is present.
|
BooleanAsyncBuilder |
matchNone(DoublePredicate filter)
Searches through the elements of the Iterable to find if unwanted elements are present.
|
static DoubleAsyncBuilder |
of(double... values)
Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable.
|
static DoubleAsyncBuilder |
of(java.lang.Iterable<java.lang.Double> iterable)
Helper function that automatically wraps a Iterable into a AsyncBuilder since it forces this collections Iterable.
|
DoubleAsyncBuilder |
onCompletion(java.util.function.Consumer<DoubleTask> callback)
Optional way to set a callback that allows to compute actions after the task was completed.
|
DoubleAsyncBuilder |
peek(DoubleConsumer action)
Allows to preview elements before they are processed
|
<E extends DoubleCollection> |
pour(E collection)
Pours all elements into a collection that can be later
|
ObjectAsyncBuilder<DoubleList> |
pourAsList()
Pours all elements into a List that can be later
|
ObjectAsyncBuilder<DoubleSet> |
pourAsSet()
Pours all elements into a Set that can be later
|
DoubleAsyncBuilder |
reduce(double identity,
DoubleDoubleUnaryOperator operator)
Reduces the elements inside of the Iterable down to one element using a identity element.
|
DoubleAsyncBuilder |
reduce(DoubleDoubleUnaryOperator operator)
Reduces the elements inside of the Iterable down to one element
|
DoubleAsyncBuilder |
repeat(int repeats)
Repeats the elements inside of the Iterable
|
DoubleAsyncBuilder |
sorted(DoubleComparator sorter)
Sorts the elements inside of the Iterable.
|
ObjectAsyncBuilder<double[]> |
toDoubleArray()
Pours all elements of the Iterable down into a Array.
|
public DoubleAsyncBuilder(DoubleIterable iterable)
iterable - that should be processedpublic DoubleAsyncBuilder(DoubleAsyncBuilder.BaseDoubleTask task)
task - that had been buildpublic static DoubleAsyncBuilder of(java.lang.Iterable<java.lang.Double> iterable)
iterable - that should be wrappedpublic static DoubleAsyncBuilder of(double... values)
values - that should be wrappedpublic <E> ObjectAsyncBuilder<E> map(DoubleFunction<E> mapper)
E - The return type.mapper - the mapping functionpublic <E,V extends java.lang.Iterable<E>> ObjectAsyncBuilder<E> flatMap(DoubleFunction<V> mapper)
V - The return type supplier.E - The return type.mapper - the flatMapping functionpublic <E> ObjectAsyncBuilder<E> arrayflatMap(DoubleFunction<E[]> mapper)
E - The return type.mapper - the flatMapping functionpublic DoubleAsyncBuilder filter(DoublePredicate filter)
filter - the elements that should be keptpublic DoubleAsyncBuilder distinct()
public DoubleAsyncBuilder repeat(int repeats)
repeats - the amount of times the elements should be repeatedpublic DoubleAsyncBuilder limit(long limit)
limit - how many elements should max be iterated throughpublic DoubleAsyncBuilder sorted(DoubleComparator sorter)
sorter - that sorts the elements.public DoubleAsyncBuilder peek(DoubleConsumer action)
action - the action that should be appliedpublic ObjectAsyncBuilder<java.lang.Void> forEach(DoubleConsumer action)
action - that should be appliedpublic DoubleAsyncBuilder reduce(DoubleDoubleUnaryOperator operator)
operator - that reduces the elements.public DoubleAsyncBuilder reduce(double identity, DoubleDoubleUnaryOperator operator)
identity - the element the reduce function should start withoperator - that reduces the elements.public ObjectAsyncBuilder<double[]> toDoubleArray()
public ObjectAsyncBuilder<DoubleList> pourAsList()
public ObjectAsyncBuilder<DoubleSet> pourAsSet()
public <E extends DoubleCollection> ObjectAsyncBuilder<E> pour(E collection)
E - the return typecollection - the collection the elementspublic BooleanAsyncBuilder matchAny(DoublePredicate filter)
filter - that decides the desired elementspublic BooleanAsyncBuilder matchNone(DoublePredicate filter)
filter - that decides the unwanted elementspublic BooleanAsyncBuilder matchAll(DoublePredicate filter)
filter - that decides the desired elementspublic DoubleAsyncBuilder findFirst(DoublePredicate filter)
filter - that decides the desired elementspublic IntAsyncBuilder count(DoublePredicate filter)
filter - that decides the desired elementspublic DoubleAsyncBuilder executor(java.util.concurrent.Executor executor)
executor - that executes the task, defaults to SanityChecks.invokeAsyncTask(Runnable)public DoubleAsyncBuilder onCompletion(java.util.function.Consumer<DoubleTask> callback)
callback - that should be notified after completion of the taskpublic DoubleTask execute()
public double join()
throws java.util.concurrent.ExecutionException,
java.lang.InterruptedException
java.util.concurrent.ExecutionException - if the task threw a exceptionjava.lang.InterruptedException - if the caller thread was interruptedpublic double join(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
timeout - of how long the thread should wait the task to be completedunit - of the desired waiting time.java.lang.InterruptedException - if the caller thread was interruptedjava.util.concurrent.ExecutionException - if the task threw a exceptionjava.util.concurrent.TimeoutException - if the timeout was reached before the task was finished