public class TweakingContext<T> extends Object
init - should init before the service and called once.
global - global scope, should be used at the system level.
thread - thread scope, should use try {tweak} finally{reset} pattern.
| Constructor and Description |
|---|
TweakingContext()
without default value
|
TweakingContext(Supplier<T> initDefault)
init with default value
|
TweakingContext(T initDefault)
init with default value
|
| Modifier and Type | Method and Description |
|---|---|
T |
current(boolean notnull)
get current value, in the order of thread, global, default value
|
T |
defaultValue(boolean notnull) |
T |
globalValue(boolean notnull) |
void |
initDefault(Supplier<T> value)
init the default value
|
void |
initDefault(T value)
init the default value
|
void |
initThread(@NotNull ThreadLocal<Supplier<T>> threadLocal,
boolean tryToCleanOld)
init thread value
|
void |
resetGlobal()
reset global value
|
void |
resetThread()
reset thread value.
|
T |
threadValue(boolean notnull) |
void |
tweakGlobal(Supplier<T> stack)
tweak global value
|
void |
tweakGlobal(T stack)
tweak global value
|
void |
tweakThread(Supplier<T> stack)
tweak thread value.
|
void |
tweakThread(T stack)
tweak thread value.
|
public TweakingContext()
public TweakingContext(T initDefault)
public void initDefault(T value)
public void initThread(@NotNull
@NotNull ThreadLocal<Supplier<T>> threadLocal,
boolean tryToCleanOld)
throws ThreadLocalAttention
ThreadLocalAttentionpublic void tweakGlobal(T stack)
public void resetGlobal()
public void tweakThread(T stack)
public void tweakThread(Supplier<T> stack)
public void resetThread()
@Contract(value="true->!null") public T globalValue(boolean notnull)
@Contract(value="true->!null") public T threadValue(boolean notnull)
@Contract(value="true->!null") public T defaultValue(boolean notnull)
@Contract(value="true->!null") public T current(boolean notnull)
Copyright © 2023. All rights reserved.