Class PersistTasks
java.lang.Object
ch.tocco.nice2.persist.core.api.exec.PersistTasks
-
Method Summary
Modifier and TypeMethodDescriptionstatic <A> PersistTask<A, Boolean> and(PersistTask<A, Boolean>... predicates) the classic 'and' behaviour for tasks which returns aBooleanstatic <A,B> PersistTaskIterable <A, B> asIterableTask(PersistTask<A, Iterable<B>> task) static <A,B> PersistTask <A, B> empty()Always returnnull.static <A,B> PersistTask <A, B> fromFunction(Function<A, B> function) Create a persist task from a guava function.static <A> PersistTask<A, Boolean> fromPredicate(Predicate<A> predicate) Create a persist task from a guava predicate.static <A> PersistTask<A, A> identity()Return the argument.static <A> PersistTask<A, Boolean> isNull()static PersistTask<String, Boolean> static <R> NoArgPersistTask<R> noArg(R object) helper method to get aNoArgPersistTaskfrom a objectstatic <A> PersistTask<A, Boolean> not(PersistTask<A, Boolean> predicate) static <A,B> PersistTask <A, B> of(B value) Creates a task that returns the given value on each run.static <A,B> OptionalTask <A, B> opt(OptionalTask<A, B> task) This is for casting lambdas to have the compiler use theOptionalTaskinterface when using combinators likePersistTask.compose(PersistTask)that expect the generalPersistTaskinterface.static <A> PersistTask<A, Boolean> or(PersistTask<A, Boolean>... predicates) the classic 'or' behaviour for tasks which returns aBooleanstatic <P,R> NoTaskDataPartitionedPersistTask <P, R> partitionIterableTask(PersistTask<Iterable<P>, Iterable<R>> task) partition a task that returns an iterablestatic PersistTask<Void, Void> partitionQuery(PrimaryKeyQueryBuilder queryBuilder, PersistTask<Iterable<Entity>, Void> task, int partitionSize) create a partitioned task from a query builder and a task to handle the partitionsstatic PersistTask<Void, Void> partitionQuery(QueryBuilder queryBuilder, PersistTask<Iterable<Entity>, Void> task, int partitionSize) Deprecated.static PersistTask<Void, Iterable<SimpleEntityId>> partitionQueryGatherIds(PrimaryKeyQueryBuilder queryBuilder, PersistTask<Iterable<Entity>, Iterable<Entity>> task, int partitionSize) create a partitioned task from a query builder and a task to handle the partitions transform returned entities into entity idsstatic <P> NoTaskDataPartitionedPersistTask<P, Void> partitionTask(PersistTask<Iterable<P>, Void> task) partition a taskstatic <A,B> PersistTask <A, B> require(OptionalTask<A, B> task) Return a new task that throws an exception if the argument is not present.static <A,B> PersistTask <A, B> require(String msg, OptionalTask<A, B> task) Return a new task that throws an exception if the argument is not present.static PersistTaskIterable<EntityList, Entity> unwrap()Unwraps theEntityin the given entity list.static PersistTaskIterable<Relation, Entity> Unwraps theEntityin the given relation.
-
Method Details
-
unwrap
Unwraps theEntityin the given entity list. -
unwrapRelation
Unwraps theEntityin the given relation. -
identity
Return the argument. -
empty
Always returnnull. -
opt
This is for casting lambdas to have the compiler use theOptionalTaskinterface when using combinators likePersistTask.compose(PersistTask)that expect the generalPersistTaskinterface. -
require
Return a new task that throws an exception if the argument is not present. Can be used to require an argument for anOptionalTask.- Parameters:
msg- the error message for the exceptiontask- the task to check the argument for
-
require
Return a new task that throws an exception if the argument is not present. Can be used to require an argument for anOptionalTask.- Parameters:
task- the task to check the argument for
-
fromFunction
Create a persist task from a guava function. -
asIterableTask
-
fromPredicate
Create a persist task from a guava predicate. -
isNull
-
isNullOrEmpty
-
not
-
or
the classic 'or' behaviour for tasks which returns aBoolean- Returns:
- true if one of the given tasks returns true, false otherwise
If the returned
Optionalof a task is absent, it will be treated as a 'false'
-
and
the classic 'and' behaviour for tasks which returns aBoolean- Returns:
- false if one of the given tasks returns false, true otherwise.
If the returned
Optionalof a task is absent, it will be treated as a 'false'
-
of
Creates a task that returns the given value on each run. -
partitionQuery
@Deprecated public static PersistTask<Void,Void> partitionQuery(QueryBuilder queryBuilder, PersistTask<Iterable<Entity>, Void> task, int partitionSize) Deprecated.create a partitioned task from a query builder and a task to handle the partitions- Parameters:
queryBuilder- the query builder to partitiontask- the task to use on each partitionpartitionSize- the size of the partitions- Returns:
- the task
-
partitionQuery
public static PersistTask<Void,Void> partitionQuery(PrimaryKeyQueryBuilder queryBuilder, PersistTask<Iterable<Entity>, Void> task, int partitionSize) create a partitioned task from a query builder and a task to handle the partitions- Parameters:
queryBuilder- the query builder to partitiontask- the task to use on each partitionpartitionSize- the size of the partitions- Returns:
- the task
-
partitionQueryGatherIds
public static PersistTask<Void,Iterable<SimpleEntityId>> partitionQueryGatherIds(PrimaryKeyQueryBuilder queryBuilder, PersistTask<Iterable<Entity>, Iterable<Entity>> task, int partitionSize) create a partitioned task from a query builder and a task to handle the partitions transform returned entities into entity ids- Parameters:
queryBuilder- the query builder to partitiontask- the task to use on each partitionpartitionSize- the size of the partitions- Returns:
- the task
-
noArg
helper method to get aNoArgPersistTaskfrom a object- Type Parameters:
R- the type of the object- Parameters:
object- the object to return- Returns:
- the no arg task
-
partitionTask
public static <P> NoTaskDataPartitionedPersistTask<P,Void> partitionTask(PersistTask<Iterable<P>, Void> task) partition a task- Type Parameters:
P- the argument type of the task, will be passed to the task in a list- Parameters:
task- the task to apply to each partition- Returns:
- the partitioned task
-
partitionIterableTask
public static <P,R> NoTaskDataPartitionedPersistTask<P,R> partitionIterableTask(PersistTask<Iterable<P>, Iterable<R>> task) partition a task that returns an iterable- Type Parameters:
P- the argument type of the task, will be passed to the task in a listR- the return type of the task, will be returned as an iterable- Parameters:
task- the task to apply to each partition- Returns:
- the partitioned task
-
partitionQuery(PrimaryKeyQueryBuilder, PersistTask, int)