public class CustomVariableContextImpl extends Object implements CustomVariableContext
Constructor and Description |
---|
CustomVariableContextImpl(VariableSubstitutorFactory variableSubstitutorFactory) |
Modifier and Type | Method and Description |
---|---|
void |
addCustomData(String key,
String value)
Adds a
VariableType.MANUAL variable to ThreadLocal state. |
void |
clearContext()
Clear
ThreadLocal state. |
Set<String> |
findAllVariables(String variable)
Given a string, and a
Map of variables (variable -> value), all patterns in the string array
matching ${bamboo.<variable>} will be substituted with the value. |
Map<String,VariableDefinitionContext> |
getBuildInRepositoryVariablesIfBuildContext()
Return variables all built-in variables produced by repository plugin for the current build context.
|
Map<String,VariableSubstitutionContext> |
getSubstitutedVariables()
Get all the variables that have previously been substituted in this thread.
|
Map<String,VariableDefinitionContext> |
getVariableContexts()
Get all variables from current thread local context.
|
VariableSubstitutorFactory |
getVariableSubstitutorFactory() |
String |
removeAllVariables(String value)
Given a string array, remove all variable patterns.
|
void |
setPlan(ImmutablePlan plan)
Sets Plan reference and default variable definitions (globals and from plan) in
ThreadLocal state. |
String |
substituteString(String value)
Substitutes variables in the input string with their values using data from existing
ThreadLocal state. |
<V,E1 extends Exception,E2 extends Exception,E3 extends Exception> |
withVariableSubstitutor(VariableSubstitutor variableSubstitutor,
BambooCallables.ThrowingX<V,E1,E2,E3> callable)
Run operation with provided
VariableSubstitutor in thread local context. |
<V> V |
withVariableSubstitutor(VariableSubstitutor variableSubstitutor,
Callable<V> callable)
Run operation with provided
VariableSubstitutor in thread local context. |
void |
withVariableSubstitutor(VariableSubstitutor variableSubstitutor,
Runnable runnable)
Run operation with provided
VariableSubstitutor in thread local context. |
<V> V |
withVariableSubstitutor(VariableSubstitutor variableSubstitutor,
Supplier<V> supplier)
Run operation with provided
VariableSubstitutor in thread local context. |
public CustomVariableContextImpl(VariableSubstitutorFactory variableSubstitutorFactory)
@NotNull public Map<String,VariableSubstitutionContext> getSubstitutedVariables()
CustomVariableContext
getSubstitutedVariables
in interface CustomVariableContext
public void addCustomData(String key, String value)
CustomVariableContext
VariableType.MANUAL
variable to ThreadLocal
state.addCustomData
in interface CustomVariableContext
key
- name of the variablevalue
- value of the variablepublic String substituteString(String value)
CustomVariableContext
ThreadLocal
state.substituteString
in interface CustomVariableContext
value
- input stringpublic void setPlan(@NotNull ImmutablePlan plan)
CustomVariableContext
ThreadLocal
state.
Clears history of substituted variables (CustomVariableContext.getSubstitutedVariables()
setPlan
in interface CustomVariableContext
public void clearContext()
CustomVariableContext
ThreadLocal
state.clearContext
in interface CustomVariableContext
@NotNull public String removeAllVariables(@NotNull String value)
removeAllVariables
in interface CustomVariableContext
value
- string values to be analyzed@NotNull public Set<String> findAllVariables(@Nullable String variable)
Map
of variables (variable -> value), all patterns in the string array
matching ${bamboo.<variable>} will be substituted with the value.findAllVariables
in interface CustomVariableContext
variable
- String value to be analyzed@NotNull public Map<String,VariableDefinitionContext> getVariableContexts()
CustomVariableContext
getVariableContexts
in interface CustomVariableContext
public Map<String,VariableDefinitionContext> getBuildInRepositoryVariablesIfBuildContext()
CustomVariableContext
BuildContext
, otherwise returned map will be empty.
Note: variables are used in repository definition, they will be resolved according to current state of the CustomVariableContext
getBuildInRepositoryVariablesIfBuildContext
in interface CustomVariableContext
@NotNull public VariableSubstitutorFactory getVariableSubstitutorFactory()
getVariableSubstitutorFactory
in interface CustomVariableContext
VariableSubstitutor
public void withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Runnable runnable)
CustomVariableContext
VariableSubstitutor
in thread local context. Restore current thread local state when finished.withVariableSubstitutor
in interface CustomVariableContext
public <V> V withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Callable<V> callable) throws Exception
CustomVariableContext
VariableSubstitutor
in thread local context. Restore current thread local state when finished.withVariableSubstitutor
in interface CustomVariableContext
Exception
public <V> V withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Supplier<V> supplier)
CustomVariableContext
VariableSubstitutor
in thread local context. Restore current thread local state when finished.withVariableSubstitutor
in interface CustomVariableContext
public <V,E1 extends Exception,E2 extends Exception,E3 extends Exception> V withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull BambooCallables.ThrowingX<V,E1,E2,E3> callable) throws E1 extends Exception, E2 extends Exception, E3 extends Exception
CustomVariableContext
VariableSubstitutor
in thread local context. Restore current thread local state when finished.withVariableSubstitutor
in interface CustomVariableContext
E1 extends Exception
Copyright © 2020 Atlassian Software Systems Pty Ltd. All rights reserved.