811678 wrote:If you mean you want to use method chaining in your Java code's use of reflection, like invoke().invoke().invoke(), then no, you cannot.
I'm doing some work with reflection and am using the class java.lang.reflect.Method to invoke methods (using the, er, "invoke" method).
One aspect of the work I'm doing involves method chaining, e.g. myObject.aMethod().anotherMethod().yetAnotherMethod();
Looking at the API docs, the invoke() method only seems to accept a single method call and its associated parameters. Can method chaining be modelled using reflection?
Thanks for any thoughts.
811678 wrote:Yeah, if you stop and think about it, given that invoke() is a method of the Method class, it would only work if invoke() returned a Method object as well.
Thank you for your swift and helpful reply. I mean the former, unfortunately. I will have to rethink my approach.