Class Variable

java.lang.Object
Behavioral.Interpreter.Variable
All Implemented Interfaces:
Expression

public final class Variable extends Object implements Expression
Terminal expression representing a variable lookup in the interpreter pattern. Implements the Expression interface.
  • Constructor Details

    • Variable

      public Variable(String name)
      Constructs a Variable expression with the specified variable name.
      Parameters:
      name - the name of the variable
  • Method Details

    • interpret

      public boolean interpret(Map<String,Boolean> ctx)
      Interprets the variable expression by looking up its value in the provided context.
      Specified by:
      interpret in interface Expression
      Parameters:
      ctx - the context map containing variable bindings
      Returns:
      the boolean value of the variable
      Throws:
      IllegalStateException - if the variable is not found in the context