Class VariableDeclarationStatement

java.lang.Object
io.github.jspinak.brobot.runner.dsl.statements.Statement
io.github.jspinak.brobot.runner.dsl.statements.VariableDeclarationStatement

public class VariableDeclarationStatement extends Statement
Represents a variable declaration statement in the Brobot DSL.

This statement declares a new variable in the current scope, optionally initializing it with a value. The variable can then be referenced in subsequent statements and expressions within its scope.

Variables must be declared before use and cannot be redeclared within the same scope. The type information helps with validation and type checking.

Example in JSON:

 {
   "statementType": "variableDeclaration",
   "name": "count",
   "type": "integer",
   "value": {"expressionType": "literal", "valueType": "integer", "value": 0}
 }
 
See Also:
  • Constructor Details

    • VariableDeclarationStatement

      public VariableDeclarationStatement()
  • Method Details

    • getName

      public String getName()
      The name of the variable being declared. This name must be unique within the current scope and will be used to reference the variable in subsequent statements.
    • getType

      public String getType()
      The data type of the variable. Common types include: "string", "integer", "double", "boolean", "object" This helps with type checking and validation during DSL execution.
    • getValue

      public Expression getValue()
      Optional initial value expression for the variable. If provided, the expression is evaluated and its result is assigned to the variable. If null, the variable is initialized with a default value based on its type.
    • setName

      public void setName(String name)
      The name of the variable being declared. This name must be unique within the current scope and will be used to reference the variable in subsequent statements.
    • setType

      public void setType(String type)
      The data type of the variable. Common types include: "string", "integer", "double", "boolean", "object" This helps with type checking and validation during DSL execution.
    • setValue

      public void setValue(Expression value)
      Optional initial value expression for the variable. If provided, the expression is evaluated and its result is assigned to the variable. If null, the variable is initialized with a default value based on its type.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object