public final class DynamicVariable extends java.lang.Object
InheritableThreadLocal
Constructor and Description |
---|
DynamicVariable(java.lang.Object init)
Creates a new dynamic variable with an initial value.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
toString() |
java.lang.Object |
value()
Returns the thread-local value of the dynamic variable.
|
DynamicVariable |
value(java.lang.Object value)
Changes the dynamic variable value.
|
java.lang.Object |
withValue(java.lang.Object value,
FunctionReference func)
Given a value, calls a function
func . |
public DynamicVariable(java.lang.Object init)
init
- the initial value.public java.lang.Object value()
public DynamicVariable value(java.lang.Object value)
value
- the new thread-local value.public java.lang.Object withValue(java.lang.Object value, FunctionReference func) throws java.lang.Throwable
func
. The previous value is put pack as the dynamic variable value
once func
has completed.value
- the value for the course of the execution of func
.func
- a 0-arity function.func
.java.lang.Throwable
- in case an exception occurs.public java.lang.String toString()
toString
in class java.lang.Object