Implements: IVariableCollection
Description
The VariableCollection allows you to implement a list of variables.
Properties
_variables
List of variables stored in the collection.
privateList<IVariable> _variables = new ArrayList<>()
Instance methods
add
Adds a new variable to the collection.
publicvoid add(IVariable variable)
- variable: IVariable - variable to be added.
clear
Clears the collection.
publicvoid clear()
clearValues
Clears all stored variables (assigns null values).
publicvoid clearValues()
findByName
Finds variable in the list by it’s name.
publicIVariable findByName(String name)
- name: String - The variable name to be found.
- returns: IVariable - Variable or null if function was not found.
findIndexByName
Finds a variable’s index in the list by it’s name.
publicint findIndexByName(String name)
- name: String - name of the variale to be found.
- returns: int - variable’s index in the list or -1 if the variable was not found.
get
Gets a variable by its index.
publicIVariable get(int index)
- index: int - variable’s index.
- returns: IVariable - retrieved variable.
getAll
Gets all variables stored in the collection
publicIVariable locate(String name)
- returns: IVariable - list with variables.
length
Gets the number of stored variables.
publicint length()
- returns: int - number of stored variables.
locate
Finds a variable in the list or creates a new one if the variable was not found.
publicIVariable locate(String name)
- name: String - name of the variable to be found.
- returns: IVariable - found or created variable.
remove
Removes a variable by its index.
publicvoid remove(int index)
- index: int - index of the variable to be removed.
removeByName
Removes a variable by it’s name.
publicvoid removeByName(String name)
- name: String - name of the variable to be removed.