Package org.wildfly.common.context
Interface Contextual<C extends Contextual<C>>
- Type Parameters:
C- the public type of the contextual object
public interface Contextual<C extends Contextual<C>>
A base class for contexts which are activated in a thread-local context.
- Author:
- David M. Lloyd
-
Method Summary
Modifier and TypeMethodDescriptionGet the context manager for this object.default voidRun the given task with this contextual object selected.default <R> RrunAction(PrivilegedAction<R> action) Run the given task with this contextual object selected.default <T,U> void runBiConsumer(BiConsumer<T, U> consumer, T param1, U param2) Run the given task with this contextual object selected.default <T,U, R> R runBiFunction(BiFunction<T, U, R> function, T param1, U param2) Run the given task with this contextual object selected.default <T,U> boolean runBiPredicate(BiPredicate<T, U> predicate, T param1, U param2) Run the given task with this contextual object selected.default <V> VrunCallable(Callable<V> callable) Run the given task with this contextual object selected.default <T> voidrunConsumer(Consumer<T> consumer, T param) Run the given task with this contextual object selected.default <T,U, E extends Exception>
voidrunExBiConsumer(ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) Run the given task with this contextual object selected.default <T,U, R, E extends Exception>
RrunExBiFunction(ExceptionBiFunction<T, U, R, E> function, T param1, U param2) Run the given task with this contextual object selected.default <T,U, E extends Exception>
booleanrunExBiPredicate(ExceptionBiPredicate<T, U, E> predicate, T param1, U param2) Run the given task with this contextual object selected.default <R> RrunExceptionAction(PrivilegedExceptionAction<R> action) Run the given task with this contextual object selected.default <T,E extends Exception>
voidrunExConsumer(ExceptionConsumer<T, E> consumer, T param) Run the given task with this contextual object selected.default <T,R, E extends Exception>
RrunExFunction(ExceptionFunction<T, R, E> function, T param) Run the given task with this contextual object selected.default <T,E extends Exception>
TrunExIntFunction(ExceptionIntFunction<T, E> function, int value) Run the given task with this contextual object selected.default <T,E extends Exception>
TrunExLongFunction(ExceptionLongFunction<T, E> function, long value) Run the given task with this contextual object selected.default <T,E extends Exception>
booleanrunExPredicate(ExceptionPredicate<T, E> predicate, T param) Run the given task with this contextual object selected.default <T,R> R runFunction(Function<T, R> function, T param) Run the given task with this contextual object selected.default <T> TrunIntFunction(IntFunction<T> function, int value) Run the given task with this contextual object selected.default <T> TrunLongFunction(LongFunction<T> function, long value) Run the given task with this contextual object selected.default <T> booleanrunPredicate(Predicate<T> predicate, T param) Run the given task with this contextual object selected.
-
Method Details
-
getInstanceContextManager
Get the context manager for this object. The implementation of this method normally should return a constant instance.- Returns:
- the context manager (must not be
null)
-
run
Run the given task with this contextual object selected.- Parameters:
runnable- the task to run (must not benull)
-
runAction
Run the given task with this contextual object selected.- Type Parameters:
R- the return value type- Parameters:
action- the task to run (must not benull)- Returns:
- the action return value
-
runExceptionAction
default <R> R runExceptionAction(PrivilegedExceptionAction<R> action) throws PrivilegedActionException Run the given task with this contextual object selected.- Type Parameters:
R- the return value type- Parameters:
action- the task to run (must not benull)- Returns:
- the action return value
- Throws:
PrivilegedActionException- if the action fails with an exception
-
runCallable
Run the given task with this contextual object selected.- Type Parameters:
V- the return value type- Parameters:
callable- the task to run (must not benull)- Returns:
- the action return value
- Throws:
Exception
-
runBiConsumer
Run the given task with this contextual object selected.- Type Parameters:
T- the first parameter typeU- the second parameter type- Parameters:
consumer- the task to run (must not benull)param1- the first parameter to pass to the taskparam2- the second parameter to pass to the task
-
runExBiConsumer
default <T,U, void runExBiConsumerE extends Exception> (ExceptionBiConsumer<T, U, throws EE> consumer, T param1, U param2) Run the given task with this contextual object selected.- Type Parameters:
T- the first parameter typeU- the second parameter typeE- the exception type- Parameters:
consumer- the task to run (must not benull)param1- the first parameter to pass to the taskparam2- the second parameter to pass to the task- Throws:
E- if an exception occurs in the task
-
runConsumer
Run the given task with this contextual object selected.- Type Parameters:
T- the parameter type- Parameters:
consumer- the task to run (must not benull)param- the parameter to pass to the task
-
runExConsumer
default <T,E extends Exception> void runExConsumer(ExceptionConsumer<T, E> consumer, T param) throws ERun the given task with this contextual object selected.- Type Parameters:
T- the parameter typeE- the exception type- Parameters:
consumer- the task to run (must not benull)param- the parameter to pass to the task- Throws:
E- if an exception occurs in the task
-
runBiFunction
Run the given task with this contextual object selected.- Type Parameters:
T- the first parameter typeU- the second parameter typeR- the return value type- Parameters:
function- the task to run (must not benull)param1- the first parameter to pass to the taskparam2- the second parameter to pass to the task- Returns:
- the action return value
-
runExBiFunction
default <T,U, R runExBiFunctionR, E extends Exception> (ExceptionBiFunction<T, U, throws ER, E> function, T param1, U param2) Run the given task with this contextual object selected.- Type Parameters:
T- the first parameter typeU- the second parameter typeR- the return value typeE- the exception type- Parameters:
function- the task to run (must not benull)param1- the first parameter to pass to the taskparam2- the second parameter to pass to the task- Returns:
- the action return value
- Throws:
E- if an exception occurs in the task
-
runFunction
Run the given task with this contextual object selected.- Type Parameters:
T- the parameter typeR- the return value type- Parameters:
function- the task to run (must not benull)param- the parameter to pass to the task- Returns:
- the action return value
-
runExFunction
default <T,R, R runExFunctionE extends Exception> (ExceptionFunction<T, R, throws EE> function, T param) Run the given task with this contextual object selected.- Type Parameters:
T- the parameter typeR- the return value typeE- the exception type- Parameters:
function- the task to run (must not benull)param- the parameter to pass to the task- Returns:
- the action return value
- Throws:
E- if an exception occurs in the task
-
runBiPredicate
Run the given task with this contextual object selected.- Type Parameters:
T- the first parameter typeU- the second parameter type- Parameters:
predicate- the task to run (must not benull)param1- the first parameter to pass to the taskparam2- the second parameter to pass to the task- Returns:
- the action return value
-
runExBiPredicate
default <T,U, boolean runExBiPredicateE extends Exception> (ExceptionBiPredicate<T, U, throws EE> predicate, T param1, U param2) Run the given task with this contextual object selected.- Type Parameters:
T- the first parameter typeU- the second parameter typeE- the exception type- Parameters:
predicate- the task to run (must not benull)param1- the first parameter to pass to the taskparam2- the second parameter to pass to the task- Returns:
- the action return value
- Throws:
E- if an exception occurs in the task
-
runPredicate
Run the given task with this contextual object selected.- Type Parameters:
T- the first parameter type- Parameters:
predicate- the task to run (must not benull)param- the parameter to pass to the task- Returns:
- the action return value
-
runExPredicate
default <T,E extends Exception> boolean runExPredicate(ExceptionPredicate<T, E> predicate, T param) throws ERun the given task with this contextual object selected.- Type Parameters:
T- the first parameter typeE- the exception type- Parameters:
predicate- the task to run (must not benull)param- the parameter to pass to the task- Returns:
- the action return value
- Throws:
E- if an exception occurs in the task
-
runIntFunction
Run the given task with this contextual object selected.- Type Parameters:
T- the return value type- Parameters:
function- the task to run (must not benull)value- the parameter to pass to the task- Returns:
- the action return value
-
runExIntFunction
default <T,E extends Exception> T runExIntFunction(ExceptionIntFunction<T, E> function, int value) throws ERun the given task with this contextual object selected.- Type Parameters:
T- the return value typeE- the exception type- Parameters:
function- the task to run (must not benull)value- the parameter to pass to the task- Returns:
- the action return value
- Throws:
E- if an exception occurs in the task
-
runLongFunction
Run the given task with this contextual object selected.- Type Parameters:
T- the return value type- Parameters:
function- the task to run (must not benull)value- the parameter to pass to the task- Returns:
- the action return value
-
runExLongFunction
default <T,E extends Exception> T runExLongFunction(ExceptionLongFunction<T, E> function, long value) throws ERun the given task with this contextual object selected.- Type Parameters:
T- the return value typeE- the exception type- Parameters:
function- the task to run (must not benull)value- the parameter to pass to the task- Returns:
- the action return value
- Throws:
E- if an exception occurs in the task
-