private <V> Expression computeWhereReturnExpr(LambdaAnalysis where,
SelectFromWhere<V> sfw, SymbExArgumentHandler parentArgumentScope) throws TypedValueVisitorException,
QueryTransformException
{
SymbExToColumns translator = config.newSymbExToColumns(SelectFromWhereLambdaArgumentHandler.fromSelectFromWhere(sfw, where, config.metamodel, parentArgumentScope, withSource));
Expression methodExpr = null;
for (int n = 0; n < where.symbolicAnalysis.paths.size(); n++)
{
PathAnalysis path = where.symbolicAnalysis.paths.get(n);
TypedValue returnVal = PathAnalysisSimplifier
.simplifyBoolean(path.getReturnValue(), config.getComparisonMethods());
SymbExPassDown returnPassdown = SymbExPassDown.with(null, true);
ColumnExpressions<?> returnColumns = returnVal.visit(translator, returnPassdown);
if (!returnColumns.isSingleColumn())
throw new QueryTransformException("Expecting single column");
Expression returnExpr = returnColumns.getOnlyColumn();
if (returnVal instanceof ConstantValue.BooleanConstant)
{
if (((ConstantValue.BooleanConstant)returnVal).val)
{
// This path returns true, so it's redundant to actually
// put true into the final code.
returnExpr = null;
}
else
{
// This path returns false, so we can ignore it
continue;
}
}
// Handle where path conditions
Expression conditionExpr = pathConditionsToExpr(translator, path);
// Merge path conditions and return value to create a value for the path
Expression pathExpr = returnExpr;
if (conditionExpr != null)
{
if (pathExpr == null)
pathExpr = conditionExpr;
else