/** * Creates a closure with three free variables and binds it to the current thread * @param type1 The type of the first free variable of the newly created closure * @param type2 The type of the second free variable of the newly created closure * @param type3 The type of the third free variable of the newly created closure * @param type4 The type of the fourth free variable of the newly created closure * @return The newly created closure */ public static <A, B, C, D> Closure4<A, B, C, D> createClosure(Class<A> type1, Class<B> type2, Class<C> type3, Class<D> type4) { Closure4<A, B, C, D> closure = new Closure4<A, B, C, D>(); CLOSURES.set(closure); return closure; }
/** * Invokes this closure once for each passed quadruple of variables. * @param vars1 The first set of variables used to invoke this closure once for each variable * @param vars2 The second set of variables used to invoke this closure once for each variable * @param vars3 The third set of variables used to invoke this closure once for each variable * @param vars4 The fourth set of variables used to invoke this closure once for each variable * @return A list of Object containing the results of each closure invocation */ public List<?> each(Iterable<? extends A> vars1, Iterable<? extends B> vars2, Iterable<? extends C> vars3, Iterable<? extends D> vars4) { return closeAll(vars1, vars2, vars3, vars4); }
/** * Invokes this closure once by applying the given quadruple of variables to it. * @param var1 The first variable used to invoke this closure * @param var2 The second variable used to invoke this closure * @param var3 The third variable used to invoke this closure * @param var4 The fourth variable used to invoke this closure * @return The result of the closure invocation */ public Object apply(A var1, B var2, C var3, D var4) { return closeOne(var1, var2, var3, var4); }
/** * Curry this closure by fixing its fourth free variable to a given value. * @param curry The value to which the third variable should be curry * @return A Closure having two free variables */ public Closure3<A, B, C> curry4(D curry) { return curry(new Closure3<A, B, C>(), curry, 4); }
/** * Curry this closure by fixing its first free variable to a given value. * @param curry The value to which the first variable should be curry * @return A Closure having two free variables */ public Closure3<B, C, D> curry1(A curry) { return curry(new Closure3<B, C, D>(), curry, 1); }
/** * Curry this closure by fixing its second free variable to a given value. * @param curry The value to which the second variable should be curry * @return A Closure having two free variables */ public Closure3<A, C, D> curry2(B curry) { return curry(new Closure3<A, C, D>(), curry, 2); }
/** * Curry this closure by fixing its third free variable to a given value. * @param curry The value to which the third variable should be curry * @return A Closure having two free variables */ public Closure3<A, B, D> curry3(C curry) { return curry(new Closure3<A, B, D>(), curry, 3); }