Package com.atlassian.bamboo.variable
Class VariableContextImpl
- java.lang.Object
-
- com.atlassian.bamboo.variable.VariableContextImpl
-
- All Implemented Interfaces:
ImmutableVariableContext
,VariableContext
,Serializable
@NotThreadSafe public class VariableContextImpl extends Object implements VariableContext, Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VariableContextImpl(Map<String,VariableDefinitionContext> definitions)
VariableContextImpl(Map<String,VariableDefinitionContext> definitions, ImmutableVariableContext parentContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLocalVariable(@NotNull String key, @NotNull String value)
Add generated local (a.k.a CUSTOM) variable to this context.void
addResultVariable(@NotNull String key, @NotNull String value)
Add generated result variable to this context.@NotNull Map<String,VariableDefinitionContext>
getEffectiveVariables()
Effective state of the variables.@NotNull Map<String,VariableDefinitionContext>
getInitialState()
Get initial state of this context, that is variables that are set at the creation of this context not including variables inherited from the parent context.@NotNull Map<String,VariableDefinitionContext>
getOriginalVariables()
The original state of variables in this context, that is, the state as it was when execution of job (environment) started, created from parent context (if applicable) and explicit 'initial state' of this context.ImmutableVariableContext
getParentContext()
Get parent context.List<VariableDefinitionContext>
getPasswordVariables()
Get all variables in current context that are considered "password" variables, i.e.@NotNull Map<String,VariableDefinitionContext>
getResultVariables()
@NotNull Map<String,VariableSubstitutionContext>
getSubstitutions()
void
removeLocalVariable(@NotNull String key)
-
-
-
Constructor Detail
-
VariableContextImpl
public VariableContextImpl(Map<String,VariableDefinitionContext> definitions, @Nullable ImmutableVariableContext parentContext)
-
VariableContextImpl
public VariableContextImpl(Map<String,VariableDefinitionContext> definitions)
-
-
Method Detail
-
getSubstitutions
@NotNull public @NotNull Map<String,VariableSubstitutionContext> getSubstitutions()
- Specified by:
getSubstitutions
in interfaceVariableContext
- Returns:
- variables used in current build
-
getOriginalVariables
@NotNull public @NotNull Map<String,VariableDefinitionContext> getOriginalVariables()
Description copied from interface:ImmutableVariableContext
The original state of variables in this context, that is, the state as it was when execution of job (environment) started, created from parent context (if applicable) and explicit 'initial state' of this context. See alsoImmutableVariableContext.getInitialState()
- Specified by:
getOriginalVariables
in interfaceImmutableVariableContext
- Returns:
- immutable state of the variables as it was when this object was created
-
getEffectiveVariables
@NotNull public @NotNull Map<String,VariableDefinitionContext> getEffectiveVariables()
Description copied from interface:ImmutableVariableContext
Effective state of the variables. This is calculated according to the following rules: - result variables hide variables from original state - local variables hide all other variables- Specified by:
getEffectiveVariables
in interfaceImmutableVariableContext
- Returns:
- immutable map containing effective state of variables in this context
-
getResultVariables
@NotNull public @NotNull Map<String,VariableDefinitionContext> getResultVariables()
- Specified by:
getResultVariables
in interfaceImmutableVariableContext
- Returns:
- immutable map containing all result variables in this context
-
getParentContext
@Nullable public ImmutableVariableContext getParentContext()
Description copied from interface:ImmutableVariableContext
Get parent context. Note that making changes to the parent context is not supported.- Specified by:
getParentContext
in interfaceImmutableVariableContext
-
getInitialState
@NotNull public @NotNull Map<String,VariableDefinitionContext> getInitialState()
Description copied from interface:ImmutableVariableContext
Get initial state of this context, that is variables that are set at the creation of this context not including variables inherited from the parent context.- Specified by:
getInitialState
in interfaceImmutableVariableContext
-
addResultVariable
public void addResultVariable(@NotNull @NotNull String key, @NotNull @NotNull String value)
Description copied from interface:VariableContext
Add generated result variable to this context. Result variables are persisted with the result and are available in subsequent stages of the plan and in deployment version created from a result. Result variables hide any global or plan variables (but their value is not changed). If a local variable exists with the same key, it will be removed. Calling this method second time with the same key assigns new value to the variable.- Specified by:
addResultVariable
in interfaceVariableContext
-
addLocalVariable
public void addLocalVariable(@NotNull @NotNull String key, @NotNull @NotNull String value)
Description copied from interface:VariableContext
Add generated local (a.k.a CUSTOM) variable to this context. Local variables are only accessible from this context and are not persisted. Local variables hide any existing variables (but their value is not changed). However if you define a result variable with the same key after defining local variable, local variable will be removed. Calling this method second time with the same key assigns new value to the variable.- Specified by:
addLocalVariable
in interfaceVariableContext
-
removeLocalVariable
public void removeLocalVariable(@NotNull @NotNull String key)
- Specified by:
removeLocalVariable
in interfaceVariableContext
-
getPasswordVariables
public List<VariableDefinitionContext> getPasswordVariables()
Description copied from interface:ImmutableVariableContext
Get all variables in current context that are considered "password" variables, i.e. contain string "password" in name.- Specified by:
getPasswordVariables
in interfaceImmutableVariableContext
-
-