/** * {@inheritDoc} */ public T exec(Object ... args) { return (T)closure.closeOne(args); } }
public Object invoke(Object proxy, Method method, Object[] args) throws WrongClosureInvocationException { return closeOne(args); } }
void closeUnhandledInvocations() { for (Object[] vars : unhandeledInvocations) { closeOne(vars); } unhandeledInvocations.clear(); }
/** * Invokes this closure once for each passed variable. * It is then assumed that this closure has been defined with exactly one free variable * @param vars The set of variables used to invoke this closure once for each variable * @return A list of Object containing the results of each closure invocation * @throws WrongClosureInvocationException if this closure hasn't been defined with exactly one free variable */ List<?> closeAll(Object... vars) throws WrongClosureInvocationException { List<Object> results = new ArrayList<Object>(); for (Object var : vars) { results.add(closeOne(var)); } return results; }
/** * Invokes this closure once for each passed set of variables. * Each iterable is used as a different set of variables with which this closure is invoked * @param vars The variables used to invoke this closure once for each set of variables * @return A list of Object containing the results of each closure invocation * @throws WrongClosureInvocationException if the number of the passed variables doesn't correspond to one * with which this closure has been defined */ List<?> closeAll(Iterable<?>... vars) throws WrongClosureInvocationException { List<Object> results = new ArrayList<Object>(); int length = vars.length; Iterator<?>[] iterators = new Iterator<?>[length]; for (int i = 0; i < length; i++) { iterators[i] = vars[i].iterator(); } while (true) { Object[] varSet = new Object[length]; if (buildParams(length, iterators, varSet)) break; results.add(closeOne(varSet)); } return results; }