Class TransactionalState
java.lang.Object
com.github.robtimus.os.windows.registry.TransactionalState
The possible transactional states.
- Author:
- Rob Spoor
- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceTransactionalState.Action<X extends Throwable>A transactional action.static interfaceTransactionalState.Callable<R, X extends Throwable>A transactional action that returns a result. -
Method Summary
Modifier and TypeMethodDescription<R, X extends Throwable>
Rcall(TransactionalState.Callable<? extends R, X> action) Runs an action.static TransactionalStateReturns a transactional state that will cause an exception to be thrown if no current transaction exists.static TransactionalStatenever()Returns a transactional state that will cause an exception to be thrown if a current transaction exists.static TransactionalStateReturns a transactional state that will not use any transaction.static TransactionalStaterequired(TransactionOption... options) Returns a transactional state that will use the current transaction if one exists, or create a new one otherwise.static TransactionalStaterequiresNew(TransactionOption... options) Returns a transactional state that will create a new transaction.<X extends Throwable>
voidrun(TransactionalState.Action<X> action) Runs an action.static TransactionalStatesupports()Returns a transactional state that will use the current transaction if one exists, or no transaction otherwise.
-
Method Details
-
mandatory
Returns a transactional state that will cause an exception to be thrown if no current transaction exists.- Returns:
- A transactional state that will cause an exception to be thrown if no current transaction exists.
-
required
Returns a transactional state that will use the current transaction if one exists, or create a new one otherwise.- Parameters:
options- The options to use when creating a new transaction. They are ignored if a current transaction exists.- Returns:
- A transactional state that will use the current transaction if one exists, or create a new one otherwise.
- Throws:
NullPointerException- If any of the given options isnull.IllegalStateException- If the given options contain different occurrences for the same option, e.g. multiple timeouts.
-
requiresNew
Returns a transactional state that will create a new transaction.- Parameters:
options- The options to use when creating a new transaction.- Returns:
- A transactional state that will create a new transaction.
- Throws:
NullPointerException- If any of the given options isnull.IllegalStateException- If the given options contain different occurrences for the same option, e.g. multiple timeouts.
-
supports
Returns a transactional state that will use the current transaction if one exists, or no transaction otherwise.- Returns:
- A transactional state that will use the current transaction if one exists, or no transaction otherwise.
-
notSupported
Returns a transactional state that will not use any transaction. If a current transaction exists it will be ignored.- Returns:
- A transactional state that will not use any transaction.
-
never
Returns a transactional state that will cause an exception to be thrown if a current transaction exists.- Returns:
- A transactional state that will cause an exception to be thrown if a current transaction exists.
-
run
Runs an action.- Type Parameters:
X- The type of exception thrown by the action.- Parameters:
action- The action to run.- Throws:
NullPointerException- If the given action isnull.UnsupportedOperationException- If the current Windows version does not support transactions.TransactionException- If a required transaction could not be created (optional).TransactionRequiredException- If amandatory transactional stateis used without a current transaction (optional).TransactionNotAllowedException- If atransactional state that does not allow transactionsis used with a current transaction (optional).X- If the action completes with an exception.- See Also:
-
call
Runs an action.- Type Parameters:
R- The action's result type.X- The type of exception thrown by the action.- Parameters:
action- The action to run.- Returns:
- The result of the action.
- Throws:
NullPointerException- If the given action isnull.UnsupportedOperationException- If the current Windows version does not support transactions.TransactionException- If a required transaction could not be created (optional).TransactionRequiredException- If amandatory transactional stateis used without a current transaction (optional).TransactionNotAllowedException- If atransactional state that does not allow transactionsis used with a current transaction (optional).X- If the action completes with an exception.- See Also:
-