Package com.ibm.dbb.task.variables
Class AbstractVariables
- java.lang.Object
-
- com.ibm.dbb.task.variables.AbstractVariables
-
- All Implemented Interfaces:
TypableVariable
- Direct Known Subclasses:
TaskVariables
public abstract class AbstractVariables extends java.lang.Object implements TypableVariable
A Property object that uses VariableGroups to create defined lookup order. All writes go to the first item in the lookup order, so any variables defined later in the lookup order are static. Replaces references to other variables within String variables and returns copies of collections to avoid unintentionally modifying the source.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractVariables.ReferenceReplacementMetadata
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(java.lang.String key)Returns true if the input key has a variable associated with it.java.util.List<AbstractVariables.ReferenceReplacementMetadata.ReferenceMetadata>getReferenceMetadata()Returns a copy of the metadata collected by the last reference replacement call.java.lang.ObjectgetVariable(java.lang.String key)Retrieves the first match for the specified key or null if there is no match.booleanisRestricted(java.lang.String key)Check whether a key is restricted.java.lang.ObjectreplaceReferences(java.lang.Object value)keydefaults to null.static java.lang.ObjectreplaceReferences(java.lang.String key, java.lang.Object value, java.util.function.Function<java.lang.String,java.lang.Object> getter)Replaces any references for the input object if possible.voidsetGroup(int index, com.ibm.dbb.task.variables.internal.VariableGroup group)Replaces a VariableGroup at an index and rechecks the restricted keys added and removed by the operation.booleansetVariable(java.lang.String key, java.lang.Object value)Writes to the value in the first open VariableGroup.voidvalidateRestrictedFields()Constructs a list of restricted keys and ensures no VariableGroups attempt to overwrite them.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.dbb.task.variables.TypableVariable
getBooleanVariable, getBooleanVariable, getBuildGroup, getBuildResult, getCommandLine, getDoubleVariable, getDoubleVariable, getIntegerVariable, getIntegerVariable, getListStringVariable, getListStringVariable, getListVariable, getListVariable, getMapVariable, getMapVariable, getSetStringVariable, getSetStringVariable, getSetVariable, getStringVariable, getStringVariable
-
-
-
-
Method Detail
-
getReferenceMetadata
public java.util.List<AbstractVariables.ReferenceReplacementMetadata.ReferenceMetadata> getReferenceMetadata()
Returns a copy of the metadata collected by the last reference replacement call.- Returns:
- List
metadata
-
setGroup
public void setGroup(int index, com.ibm.dbb.task.variables.internal.VariableGroup group) throws com.ibm.dbb.task.configuration.ConfigurationExceptionReplaces a VariableGroup at an index and rechecks the restricted keys added and removed by the operation.- Parameters:
index- the index to set.group- the VariableGroup to replace the item with.- Throws:
com.ibm.dbb.task.configuration.ConfigurationException- if a restricted key is overridden by the inserted variable group.
-
validateRestrictedFields
public void validateRestrictedFields() throws com.ibm.dbb.task.configuration.ConfigurationExceptionConstructs a list of restricted keys and ensures no VariableGroups attempt to overwrite them.- Throws:
com.ibm.dbb.task.configuration.ConfigurationException- if a restricted key is overridden by a VariableGroup.
-
isRestricted
public boolean isRestricted(java.lang.String key) throws com.ibm.dbb.task.configuration.ConfigurationExceptionCheck whether a key is restricted.- Parameters:
key- the key to check.- Returns:
- a boolean, true if the key is restricted.
- Throws:
com.ibm.dbb.task.configuration.ConfigurationException- on validation of restricted fields if a restricted key if overridden by a VariableGroup.
-
getVariable
public java.lang.Object getVariable(java.lang.String key) throws BuildExceptionRetrieves the first match for the specified key or null if there is no match. Replacing all references in the process.- Specified by:
getVariablein interfaceTypableVariable- Parameters:
key- the key to match.- Returns:
- Object or null if no match is found.
- Throws:
BuildException- on issues evaluating a conditional statement.
-
setVariable
public boolean setVariable(java.lang.String key, java.lang.Object value) throws com.ibm.dbb.task.configuration.ConfigurationExceptionWrites to the value in the first open VariableGroup. The values source is set to the currently executing task.- Parameters:
key- the key to match.value- the value to assign.- Returns:
- boolean, indicating success. False if there was no writable layer found.
- Throws:
com.ibm.dbb.task.configuration.ConfigurationException
-
contains
public boolean contains(java.lang.String key)
Returns true if the input key has a variable associated with it.- Parameters:
key- the key to test- Returns:
- true if the key has a variable associated with it. False otherwise.
-
replaceReferences
public java.lang.Object replaceReferences(java.lang.Object value) throws BuildExceptionkeydefaults to null.getterdefaults togetDefaultGetter()- Throws:
BuildException- See Also:
replaceReferences(String, Object, Function)
-
replaceReferences
public static java.lang.Object replaceReferences(java.lang.String key, java.lang.Object value, java.util.function.Function<java.lang.String,java.lang.Object> getter) throws BuildExceptionReplaces any references for the input object if possible. Returning a copy of its content if it's a Collection.- Parameters:
key- the key associated with the input value. Null if the value does not originate from an AbstractVariables object.value- the value to perform replacement on.getter- the getter that provides values for input reference keys.- Returns:
- the input object with all valid references replaced.
- Throws:
BuildException
-
-