public void filter(Filter filter) throws NoTestsRemainException { synchronized (fChildrenLock) { List<T> filteredChildren = new ArrayList<T>(getFilteredChildren()); for (Iterator<T> iter = filteredChildren.iterator(); iter.hasNext(); ) { T each = iter.next(); if (shouldRun(filter, each)) { try { filter.apply(each); } catch (NoTestsRemainException e) { iter.remove(); } } else { iter.remove(); } } fFilteredChildren = Collections.unmodifiableCollection(filteredChildren); if (fFilteredChildren.isEmpty()) { throw new NoTestsRemainException(); } } }
private void filterChild(T child) throws NoTestsRemainException { if (fFilter != null) fFilter.apply(child); }