// Extract the lambda used
LambdaAnalysis lambda = null;
if (val.args.size() > 0)
{
if (!(val.args.get(0) instanceof LambdaFactory))
throw new TypedValueVisitorException("Expecting a lambda factory for aggregate method");
LambdaFactory lambdaFactory = (LambdaFactory)val.args.get(0);
try {
lambda = LambdaAnalysis.analyzeMethod(config.metamodel, config.alternateClassLoader, config.isObjectEqualsSafe,
lambdaFactory.getLambdaMethod(), lambdaFactory.getCapturedArgs(), true);
} catch (Exception e)
{
throw new TypedValueVisitorException("Could not analyze the lambda code", e);
}
}
try {
JPQLQuery<?> transformedQuery;
if (sig.equals(MethodChecker.streamDistinct))
{
DistinctTransform transform = new DistinctTransform(config);
transformedQuery = transform.apply(subQuery, argHandler);
}
else if (sig.equals(MethodChecker.streamSelect))
{
SelectTransform transform = new SelectTransform(config, false);
transformedQuery = transform.apply(subQuery, lambda, argHandler);
}
else if (sig.equals(MethodChecker.streamWhere))
{
WhereTransform transform = new WhereTransform(config, false);
transformedQuery = transform.apply(subQuery, lambda, argHandler);
}
else if (sig.equals(MethodChecker.streamJoin))
{
JoinTransform transform = new JoinTransform(config, false);
transformedQuery = transform.apply(subQuery, lambda, argHandler);
}
else
throw new TypedValueVisitorException("Unknown stream operation: " + sig);
return transformedQuery;
}
catch (QueryTransformException e)
{
throw new TypedValueVisitorException("Subquery could not be transformed.", e);
}
// // Return the aggregated columns that we've now calculated
// if (transformedQuery.getClass() == SelectOnly.class)
// {
// SelectOnly<?> select = (SelectOnly<?>)transformedQuery;