Package: groovy.sql

## [Java] Class SqlWhereVisitor

- groovy.sql.SqlWhereVisitor

-     public class SqlWhereVisitor
      extends CodeVisitorSupport

  AST visitor used by DataSet to derive an SQL `WHERE` clause and positional parameter list from a supported filter closure.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public List<Object>` | `getParameters()` Returns the positional parameters collected while building the SQL fragment.
    `` | `public String` | `getWhere()` Returns the SQL `WHERE` fragment built so far.
    `` | `public void` | `setClosure(Closure<?> closure)` Supplies the closure whose captured variables may be referenced while the SQL fragment is being derived.
    `` | `protected String` | `tokenAsSql(Token token)` Maps a Groovy AST token to its SQL operator representation.
    `` | `public void` | `visitBinaryExpression(BinaryExpression expression)` Visits a binary expression and renders it as SQL, collecting any literal values as parameters.
    `` | `public void` | `visitBooleanExpression(BooleanExpression expression)` Visits the wrapped boolean expression.
    `` | `public void` | `visitConstantExpression(ConstantExpression expression)` Adds a constant value as a positional parameter.
    `` | `public void` | `visitPropertyExpression(PropertyExpression expression)` Appends a property reference as a column name.
    `` | `public void` | `visitReturnStatement(ReturnStatement statement)` Visits the closure return expression that defines the filter.
    `` | `public void` | `visitVariableExpression(VariableExpression expression)` Resolves a variable captured from the enclosing closure scope and adds it as a positional parameter.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class CodeVisitorSupport` | `afterSwitchCaseStatementsVisited, afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSwitchExpression, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop, visitYieldStatement`

- - ### Method Detail

    - #### public List<Object> getParameters()

      Returns the positional parameters collected while building the SQL fragment.

      Returns:
        the collected parameter values

    - #### public String getWhere()

      Returns the SQL `WHERE` fragment built so far.

      Returns:
        the derived where fragment

    - #### public void setClosure(Closure<?> closure)

      Supplies the closure whose captured variables may be referenced while the SQL fragment is being derived.

      Parameters:
        `closure` - the closure currently being translated
      Since:
        6.0.0

    - #### protected String tokenAsSql(Token token)

      Maps a Groovy AST token to its SQL operator representation.

      Parameters:
        `token` - the AST token to translate
      Returns:
        the SQL operator text

    - #### public void visitBinaryExpression(BinaryExpression expression)

      Visits a binary expression and renders it as SQL, collecting any literal values as parameters.

      Parameters:
        `expression` - the binary expression to visit

    - #### public void visitBooleanExpression(BooleanExpression expression)

      Visits the wrapped boolean expression.

      Parameters:
        `expression` - the boolean expression to visit

    - #### public void visitConstantExpression(ConstantExpression expression)

      Adds a constant value as a positional parameter.

      Parameters:
        `expression` - the constant expression to visit

    - #### public void visitPropertyExpression(PropertyExpression expression)

      Appends a property reference as a column name.

      Parameters:
        `expression` - the property expression to visit

    - #### public void visitReturnStatement(ReturnStatement statement)

      Visits the closure return expression that defines the filter.

      Parameters:
        `statement` - the return statement to visit

    - #### public void visitVariableExpression(VariableExpression expression)

      Resolves a variable captured from the enclosing closure scope and adds it as a positional parameter.

      Parameters:
        `expression` - the variable expression to visit