public class CharAsyncBuilder
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 |
CharAsyncBuilder.BaseCharTask
Base Task of the Actions that can be performed.
|
| Constructor and Description |
|---|
CharAsyncBuilder(CharAsyncBuilder.BaseCharTask task)
Helper constructor.
|
CharAsyncBuilder(CharIterable iterable)
Main Constructor that uses a Iterable to build a Offthread Task.
|
| Modifier and Type | Method and Description |
|---|---|
<E> ObjectAsyncBuilder<E> |
arrayflatMap(Char2ObjectFunction<E[]> mapper)
Maps the elements to something else
|
IntAsyncBuilder |
count(Char2BooleanFunction filter)
Counts all desired elements inside the Iterable
|
CharAsyncBuilder |
distinct()
Removes duplicated elements out of the Iterable
|
CharTask |
execute()
Starts the Execution of the task without awaiting its result
|
CharAsyncBuilder |
executor(java.util.concurrent.Executor executor)
Optional way to add a custom executor that runs this offthread task.
|
CharAsyncBuilder |
filter(Char2BooleanFunction filter)
Filters out the unwanted elements out of the Iterable
|
CharAsyncBuilder |
findFirst(Char2BooleanFunction filter)
Searches through the elements of the Iterable to find if the desired element.
|
<E,V extends java.lang.Iterable<E>> |
flatMap(Char2ObjectFunction<V> mapper)
Maps the elements to something else
|
ObjectAsyncBuilder<java.lang.Void> |
forEach(CharConsumer action)
Iterates over the Iterable with a desired action
|
char |
join()
Starts the Execution of the task and will await its completion, returning the result.
|
char |
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.
|
CharAsyncBuilder |
limit(long limit)
Limits how many elements are inside of the Iterable
|
<E> ObjectAsyncBuilder<E> |
map(Char2ObjectFunction<E> mapper)
Maps the elements to something else
|
BooleanAsyncBuilder |
matchAll(Char2BooleanFunction filter)
Searches through the elements of the Iterable to find if all the desired elements are present.
|
BooleanAsyncBuilder |
matchAny(Char2BooleanFunction filter)
Searches through the elements of the Iterable to find if the desired element is present.
|
BooleanAsyncBuilder |
matchNone(Char2BooleanFunction filter)
Searches through the elements of the Iterable to find if unwanted elements are present.
|
static CharAsyncBuilder |
of(char... values)
Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable.
|
static CharAsyncBuilder |
of(java.lang.Iterable<java.lang.Character> iterable)
Helper function that automatically wraps a Iterable into a AsyncBuilder since it forces this collections Iterable.
|
CharAsyncBuilder |
onCompletion(java.util.function.Consumer<CharTask> callback)
Optional way to set a callback that allows to compute actions after the task was completed.
|
CharAsyncBuilder |
peek(CharConsumer action)
Allows to preview elements before they are processed
|
<E extends CharCollection> |
pour(E collection)
Pours all elements into a collection that can be later
|
ObjectAsyncBuilder<CharList> |
pourAsList()
Pours all elements into a List that can be later
|
ObjectAsyncBuilder<CharSet> |
pourAsSet()
Pours all elements into a Set that can be later
|
CharAsyncBuilder |
reduce(char identity,
CharCharUnaryOperator operator)
Reduces the elements inside of the Iterable down to one element using a identity element.
|
CharAsyncBuilder |
reduce(CharCharUnaryOperator operator)
Reduces the elements inside of the Iterable down to one element
|
CharAsyncBuilder |
sorted(CharComparator sorter)
Sorts the elements inside of the Iterable.
|
public CharAsyncBuilder(CharIterable iterable)
iterable - that should be processedpublic CharAsyncBuilder(CharAsyncBuilder.BaseCharTask task)
task - that had been buildpublic static CharAsyncBuilder of(java.lang.Iterable<java.lang.Character> iterable)
iterable - that should be wrappedpublic static CharAsyncBuilder of(char... values)
values - that should be wrappedpublic <E> ObjectAsyncBuilder<E> map(Char2ObjectFunction<E> mapper)
E - The return type.mapper - the mapping functionpublic <E,V extends java.lang.Iterable<E>> ObjectAsyncBuilder<E> flatMap(Char2ObjectFunction<V> mapper)
V - The return type supplier.E - The return type.mapper - the flatMapping functionpublic <E> ObjectAsyncBuilder<E> arrayflatMap(Char2ObjectFunction<E[]> mapper)
E - The return type.mapper - the flatMapping functionpublic CharAsyncBuilder filter(Char2BooleanFunction filter)
filter - the elements that should be keptpublic CharAsyncBuilder distinct()
public CharAsyncBuilder limit(long limit)
limit - how many elements should max be iterated throughpublic CharAsyncBuilder sorted(CharComparator sorter)
sorter - that sorts the elements.public CharAsyncBuilder peek(CharConsumer action)
action - the action that should be appliedpublic ObjectAsyncBuilder<java.lang.Void> forEach(CharConsumer action)
action - that should be appliedpublic CharAsyncBuilder reduce(CharCharUnaryOperator operator)
operator - that reduces the elements.public CharAsyncBuilder reduce(char identity, CharCharUnaryOperator operator)
identity - the element the reduce function should start withoperator - that reduces the elements.public ObjectAsyncBuilder<CharList> pourAsList()
public ObjectAsyncBuilder<CharSet> pourAsSet()
public <E extends CharCollection> ObjectAsyncBuilder<E> pour(E collection)
E - the return typecollection - the collection the elementspublic BooleanAsyncBuilder matchAny(Char2BooleanFunction filter)
filter - that decides the desired elementspublic BooleanAsyncBuilder matchNone(Char2BooleanFunction filter)
filter - that decides the unwanted elementspublic BooleanAsyncBuilder matchAll(Char2BooleanFunction filter)
filter - that decides the desired elementspublic CharAsyncBuilder findFirst(Char2BooleanFunction filter)
filter - that decides the desired elementspublic IntAsyncBuilder count(Char2BooleanFunction filter)
filter - that decides the desired elementspublic CharAsyncBuilder executor(java.util.concurrent.Executor executor)
executor - that executes the task, defaults to SanityChecks.invokeAsyncTask(Runnable)public CharAsyncBuilder onCompletion(java.util.function.Consumer<CharTask> callback)
callback - that should be notified after completion of the taskpublic CharTask execute()
public char 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 char 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