This class renders and converts a GString query with embedded variables and closures
into a simple Query-String and Parameter-Object[] pair.
Embedded variables (including another GString) are rendered into the resulting String directly,
while return values of closures are extracted and added as parameter.
Closures need to either be argument less or declare exactly one argument of type StringWriter.
If a StringWriter argument is declared, then the return value of the closure is ignored.
Example:
long param1 = 10
long param2 = 20
Mandant mandant = ... //Id = 30
String name = 'Bobby Tables'
GString queryPart = "Id = $param1 or Id = ${->param2} or Name like ${ sw -> sw.append('%').append(name).append('%') }"
GString query = "BO a where not Ldel and (queryPart) and Mandant=${-> mandant}"
is converted into:
TBO a where not Ldel and (Id = $1 or Id = $2 or Name like $3) and Mandant=$4
With parameters:
[10, 20, "%Bobby Tables%", 30]
Do not insert String variables directly with surrounding quotation marks, as this will trigger a Bobby Tables warning.
BOs embedded directly, e.g. "Mandant=$mandant" will throw a
LittleBobbyTablesException
.