@Test @SuppressWarnings("unchecked") public void testChainedClosure() { MockClosure<Object> a = new MockClosure<Object>(); MockClosure<Object> b = new MockClosure<Object>(); ClosureUtils.chainedClosure(a, b).execute(null); assertEquals(1, a.count); assertEquals(1, b.count); a = new MockClosure<Object>(); b = new MockClosure<Object>(); ClosureUtils.<Object>chainedClosure(new Closure[] {a, b, a}).execute(null); assertEquals(2, a.count); assertEquals(1, b.count); a = new MockClosure<Object>(); b = new MockClosure<Object>(); Collection<Closure<Object>> coll = new ArrayList<Closure<Object>>(); coll.add(b); coll.add(a); coll.add(b); ClosureUtils.<Object>chainedClosure(coll).execute(null); assertEquals(1, a.count); assertEquals(2, b.count); assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(new Closure[0])); assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(Collections.<Closure<Object>>emptyList())); try { ClosureUtils.chainedClosure(null, null); fail(); } catch (final NullPointerException ex) {} try { ClosureUtils.<Object>chainedClosure((Closure[]) null); fail(); } catch (final NullPointerException ex) {} try { ClosureUtils.<Object>chainedClosure((Collection<Closure<Object>>) null); fail(); } catch (final NullPointerException ex) {} try { ClosureUtils.<Object>chainedClosure(new Closure[] {null, null}); fail(); } catch (final NullPointerException ex) {} try { coll = new ArrayList<Closure<Object>>(); coll.add(null); coll.add(null); ClosureUtils.chainedClosure(coll); fail(); } catch (final NullPointerException ex) {} }
public static <E> Closure<E> chainedClosure(final Closure<? super E>... closures) { return ChainedClosure.chainedClosure(closures); }
ClosureUtils { public static <E> Closure<E> chainedClosure(final Closure<? super E>... closures) { return ChainedClosure.chainedClosure(closures); } }
ClosureUtils { public static <E> Closure<E> chainedClosure(final Closure<? super E>... closures) { return ChainedClosure.chainedClosure(closures); } private  ClosureUtils(); }
ClosureUtils { public static <E> Closure<E> chainedClosure(final Closure<? super E>... closures) { return ChainedClosure.chainedClosure(closures); } private  ClosureUtils(); static Closure<E> exceptionClosure(); static Closure<E> nopClosure(); static Closure<E> asClosure(final Transformer<? super E, ?> transformer); static Closure<E> forClosure(final int count, final Closure<? super E> closure); static Closure<E> whileClosure(final Predicate<? super E> predicate, final Closure<? super E> closure); static Closure<E> doWhileClosure(final Closure<? super E> closure,
                                                final Predicate<? super E> predicate); static Closure<E> invokerClosure(final String methodName); static Closure<E> invokerClosure(final String methodName, final Class<?>[] paramTypes,
                                                final Object[] args); static Closure<E> chainedClosure(final Closure<? super E>... closures); static Closure<E> chainedClosure(final Collection<? extends Closure<? super E>> closures); static Closure<E> ifClosure(final Predicate<? super E> predicate,
                                           final Closure<? super E> trueClosure); static Closure<E> ifClosure(final Predicate<? super E> predicate,
                                           final Closure<? super E> trueClosure,
                                           final Closure<? super E> falseClosure); static Closure<E> switchClosure(final Predicate<? super E>[] predicates,
                                               final Closure<? super E>[] closures); static Closure<E> switchClosure(final Predicate<? super E>[] predicates,
                                               final Closure<? super E>[] closures,
                                               final Closure<? super E> defaultClosure); static Closure<E> switchClosure(final Map<Predicate<E>, Closure<E>> predicatesAndClosures); @SuppressWarnings("unchecked") static Closure<E> switchMapClosure(final Map<? extends E, Closure<E>> objectsAndClosures); }
ClosureUtils { public static <E> Closure<E> chainedClosure(final Closure<? super E>... closures) { return ChainedClosure.chainedClosure(closures); } private  ClosureUtils(); static Closure<E> exceptionClosure(); static Closure<E> nopClosure(); static Closure<E> asClosure(final Transformer<? super E, ?> transformer); static Closure<E> forClosure(final int count, final Closure<? super E> closure); static Closure<E> whileClosure(final Predicate<? super E> predicate, final Closure<? super E> closure); static Closure<E> doWhileClosure(final Closure<? super E> closure,
                                                final Predicate<? super E> predicate); static Closure<E> invokerClosure(final String methodName); static Closure<E> invokerClosure(final String methodName, final Class<?>[] paramTypes,
                                                final Object[] args); static Closure<E> chainedClosure(final Closure<? super E>... closures); static Closure<E> chainedClosure(final Collection<? extends Closure<? super E>> closures); static Closure<E> ifClosure(final Predicate<? super E> predicate,
                                           final Closure<? super E> trueClosure); static Closure<E> ifClosure(final Predicate<? super E> predicate,
                                           final Closure<? super E> trueClosure,
                                           final Closure<? super E> falseClosure); static Closure<E> switchClosure(final Predicate<? super E>[] predicates,
                                               final Closure<? super E>[] closures); static Closure<E> switchClosure(final Predicate<? super E>[] predicates,
                                               final Closure<? super E>[] closures,
                                               final Closure<? super E> defaultClosure); static Closure<E> switchClosure(final Map<Predicate<E>, Closure<E>> predicatesAndClosures); @SuppressWarnings("unchecked") static Closure<E> switchMapClosure(final Map<? extends E, Closure<E>> objectsAndClosures);  }