public class FunctionalTransaction<T> extends Object
FunctionalTransaction can have possible
side effects and thus can have rollback and commit operations.VoidTransaction| Constructor and Description |
|---|
FunctionalTransaction(FunctionWithException<I,T> function,
FunctionalTransaction<I> previous)
Constructs a lightweight transaction chained to a previous one.
|
FunctionalTransaction(SupplierWithException<T> function)
Constructs a lightweight transaction that can have a rollback and a commit.
|
| Modifier and Type | Method and Description |
|---|---|
<R> FunctionalTransaction<Pair<T,R>> |
and(FunctionWithException<T,R> f)
Creates another transaction and chains it to this one preserving the intermediate result.
|
FunctionalTransaction<T> |
retry(int times)
Specify the number of retires for the evaluation of this function.
|
<R> FunctionalTransaction<R> |
then(FunctionWithException<T,R> function)
Creates another transaction and chains it to this one.
|
FunctionalTransaction<T> |
withCommit(java.util.function.Consumer<T> commit)
Specify the commit for this function.
|
FunctionalTransaction<T> |
withReset(java.util.function.Consumer<T> rollback)
Alias for
withRollback(Consumer) |
FunctionalTransaction<T> |
withRollback(java.util.function.Consumer<T> rollback)
Specify the rollback for this function.
|
FunctionalTransaction<T> |
withRollback(Runnable rollback)
Specify the rollback for this function.
|
FunctionalTransaction<T> |
withVerification(java.util.function.Function<T,Boolean> verification)
Specify the verification for this function.
|
public FunctionalTransaction(SupplierWithException<T> function)
function - the function to evaluate.public FunctionalTransaction(FunctionWithException<I,T> function, FunctionalTransaction<I> previous)
I - the input type of the functionfunction - the function to evaluate.previous - the FunctionalTransaction to attach topublic FunctionalTransaction<T> withReset(java.util.function.Consumer<T> rollback)
withRollback(Consumer)rollback - the Runnable to perform in order to rollback any side effects of the transactionpublic FunctionalTransaction<T> withRollback(java.util.function.Consumer<T> rollback)
rollback - the Consumer to perform in order to rollback any side effects of the transactionpublic FunctionalTransaction<T> withRollback(Runnable rollback)
rollback - the Runnable to perform in order to rollback any side effects of the transactionpublic FunctionalTransaction<T> withCommit(java.util.function.Consumer<T> commit)
commit - the Consumer to perform in order to commit any side effects of this transactionpublic FunctionalTransaction<T> withVerification(java.util.function.Function<T,Boolean> verification)
verification - - a Supplier that returns false if there has been an errorpublic FunctionalTransaction<T> retry(int times)
times - the number of times this transaction should be retried before giving uppublic <R> FunctionalTransaction<R> then(FunctionWithException<T,R> function)
R - the return type of the new transactionfunction - a function that takes the output of this transaction and returns a new valuepublic <R> FunctionalTransaction<Pair<T,R>> and(FunctionWithException<T,R> f)
Pair conatining the result of this transaction
and the result of the function passed.R - the return type of the new transactionf - a function that takes the output of this transaction and returns a new valueCopyright © 2019. All rights reserved.