Class MapDelegateVariableContainer
- java.lang.Object
-
- org.flowable.common.engine.impl.variable.MapDelegateVariableContainer
-
- All Implemented Interfaces:
VariableContainer
public class MapDelegateVariableContainer extends Object implements VariableContainer
A simple VariableContainer implementation with the ability to add transient variables in addition to a VariableContainer. ThegetVariable(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 Modifier and Type Field Description protected VariableContainerdelegateprotected Map<String,Object>transientVariables
-
Constructor Summary
Constructors Constructor Description MapDelegateVariableContainer()MapDelegateVariableContainer(Map<String,Object> transientVariables, VariableContainer delegate)MapDelegateVariableContainer(VariableContainer delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MapDelegateVariableContaineraddTransientVariable(String key, Object variable)Convenience method which returnsthisfor method concatenation.voidclearTransientVariables()Clears all transient variables of this variable container (not touching the delegate).StringgetTenantId()Map<String,Object>getTransientVariables()ObjectgetVariable(String key)The method first looks if there is a local transient variable and returns it.booleanhasVariable(String key)Checks whether the given key can be resolved by this variable container.MapDelegateVariableContainerremoveTransientVariable(String key)voidsetTransientVariable(String key, Object value)Sets a transient variable, which is local to this variable container.voidsetVariable(String key, Object value)Sets the variable to the delegate.
-
-
-
Field Detail
-
delegate
protected final VariableContainer delegate
-
-
Constructor Detail
-
MapDelegateVariableContainer
public MapDelegateVariableContainer(Map<String,Object> transientVariables, VariableContainer delegate)
-
MapDelegateVariableContainer
public MapDelegateVariableContainer(VariableContainer delegate)
-
MapDelegateVariableContainer
public MapDelegateVariableContainer()
-
-
Method Detail
-
hasVariable
public boolean hasVariable(String key)
Checks whether the given key can be resolved by this variable container.- Specified by:
hasVariablein 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(String)
-
getVariable
public Object getVariable(String key)
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:
getVariablein interfaceVariableContainer- Returns:
- the variable of this variable container, the delegate container if not defined here or null when not found in either.
-
setVariable
public void setVariable(String key, Object value)
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:
setVariablein interfaceVariableContainer- Parameters:
key- the variable namevalue- the variable value to set to the delegate
-
setTransientVariable
public void setTransientVariable(String key, Object value)
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:
setTransientVariablein interfaceVariableContainer- Parameters:
key- the variable namevalue- the variable value- See Also:
addTransientVariable(String, Object)
-
addTransientVariable
public MapDelegateVariableContainer addTransientVariable(String key, Object variable)
Convenience method which returnsthisfor method concatenation. Same assetTransientVariable(String, Object)
-
clearTransientVariables
public void clearTransientVariables()
Clears all transient variables of this variable container (not touching the delegate).
-
getTransientVariables
public Map<String,Object> getTransientVariables()
- Returns:
- all available transient variables
-
removeTransientVariable
public MapDelegateVariableContainer removeTransientVariable(String key)
-
getTenantId
public String getTenantId()
- Specified by:
getTenantIdin interfaceVariableContainer
-
-