Thanks Feng. I want to access elements before evaluation. Use your example:
Define: public static List<Long> myFunc() { return Arrays.asList(1L, 2L); } public static Long myFunc2(Long i) { return i - 1l } I want build expressions as the following: List<Expression> ret = new ArrayList(); MethodCallExpression mce = Expressions.call(SqlFunctions.class,"myFunc"); // how to make each element an expression? for (Expression expr : mce) { ret.dd(Expressions.call(SqlFunctions.class, "myFunc2", expr)); } return ret; As you can see, I know "myFunc" returns a list, so I want to make each element of that list an expression so I can continue manipulating them. Eventually they will be used to generate code. -Rui On Mon, Dec 30, 2019 at 9:29 PM Feng Zhu <wellfeng...@gmail.com> wrote: > > > > Basically I know the function return a list so I want to access each > > element of it. Ideally I can get a List<Expression> ret = > > Expressions.call(FindMethod("myFunc")) > > > Can you elaborate on what do you want? i.e., *List<Expression> ret* > If you want to get the element of a method call result, you can evaluate > the expression and cast it to list. > > For example, assume "myFunc" in SqlFunctions. > > > > * public static List<Long> myFunc() { return Arrays.asList(1L, 2L); }* > > > * MethodCallExpression mce = Expressions.call(SqlFunctions.class, > "myFunc"); List<Long> ret = (List<Long>) Expressions.evaluate(mce);* > > Best, > > Rui Wang <amaliu...@apache.org> 于2019年12月31日周二 下午12:14写道: > > > Hi community, > > > > Let's say I define a function like this: > > > > List<Long> myFunc() { > > // function body > > // do something > > // return a list of long > > } > > > > Then by linq4j library, I can > > > > Expression ret = Expressions.call( > > FindMethod("myFunc") > > ) > > > > > > my question is, how to make the returned expression of the call to be a > > list, or something equivalent? > > > > Basically I know the function return a list so I want to access each > > element of it. Ideally I can get a List<Expression> ret = > > Expressions.call(FindMethod("myFunc")) > > > > > > -Rui > > >