Class MapDelegateVariableContainer
java.lang.Object
org.flowable.common.engine.impl.variable.MapDelegateVariableContainer
- All Implemented Interfaces:
VariableContainer
A simple VariableContainer implementation with the ability to
add transient variables in addition to a VariableContainer.
The
getVariable(String)
method first looks if there is a
local transient variable and returns it, if not, the delegate method is called.
In case there is also a variable with the same key here as well as in the delegate,
the delegate is ignored, effectively shadowing the variable of the delegate.- Author:
- Arthur Hupka-Merle
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMapDelegateVariableContainer
(Map<String, Object> transientVariables, VariableContainer delegate) -
Method Summary
Modifier and TypeMethodDescriptionaddTransientVariable
(String key, Object variable) Convenience method which returnsthis
for method concatenation.void
Clears all transient variables of this variable container (not touching the delegate).getVariable
(String key) The method first looks if there is a local transient variable and returns it.boolean
hasVariable
(String key) Checks whether the given key can be resolved by this variable container.void
setTransientVariable
(String key, Object value) Sets a transient variable, which is local to this variable container.void
setVariable
(String key, Object value) Sets the variable to the delegate.toString()
-
Field Details
-
transientVariables
-
delegate
-
-
Constructor Details
-
MapDelegateVariableContainer
public MapDelegateVariableContainer(Map<String, Object> transientVariables, VariableContainer delegate) -
MapDelegateVariableContainer
-
MapDelegateVariableContainer
public MapDelegateVariableContainer()
-
-
Method Details
-
hasVariable
Checks whether the given key can be resolved by this variable container.- Specified by:
hasVariable
in interfaceVariableContainer
- Parameters:
key
- the name of the variable- Returns:
- true in case this variable container defines a variable with the given key.
- See Also:
-
getVariable
The method first looks if there is a local transient variable and returns it. If not, the delegate method is called. In case there is also a variable with the same key here as well as in the delegate, the delegate is ignored, effectively shadowing the variable of the delegate.- Specified by:
getVariable
in interfaceVariableContainer
- Returns:
- the variable of this variable container, the delegate container if not defined here or null when not found in either.
-
setVariable
Sets the variable to the delegate. NOTE: this does not add the variable to this variable container, but to the delegate. Only in case delegate isVariableContainer.empty()
it is set as transient variable for this container to ensure consistent behavior, when using this variable container without a delegate. UseaddTransientVariable(String, Object)
to add variables local to this variable container only.- Specified by:
setVariable
in interfaceVariableContainer
- Parameters:
key
- the variable namevalue
- the variable value to set to the delegate
-
setTransientVariable
Sets a transient variable, which is local to this variable container. Transient variables take precedence over variables for the delegate VariableContainer. Therefore, transient variables do shadow potentially available variables with the same name in the delegate.- Specified by:
setTransientVariable
in interfaceVariableContainer
- Parameters:
key
- the variable namevalue
- the variable value- See Also:
-
addTransientVariable
Convenience method which returnsthis
for method concatenation. Same assetTransientVariable(String, Object)
-
clearTransientVariables
public void clearTransientVariables()Clears all transient variables of this variable container (not touching the delegate). -
getTransientVariables
- Returns:
- all available transient variables
-
removeTransientVariable
-
getTenantId
- Specified by:
getTenantId
in interfaceVariableContainer
-
toString
-