Class 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.
    • Method Detail

      • setGroup

        public void setGroup​(int index,
                             com.ibm.dbb.task.variables.internal.VariableGroup group)
                      throws com.ibm.dbb.task.configuration.ConfigurationException
        Replaces 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.ConfigurationException
        Constructs 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.ConfigurationException
        Check 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 BuildException
        Retrieves the first match for the specified key or null if there is no match. Replacing all references in the process.
        Specified by:
        getVariable in interface TypableVariable
        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.ConfigurationException
        Writes 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 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 BuildException
        Replaces 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