/** * Filter a list of tables through each matcher using a list of matchers sequentially. * * @param candidateTables The collection of tables to be filtered * @param matchers The matchers to apply, in order * * @return A set of tables which satisfy all matchers * * @throws NoMatchFoundException if no tables match the filter */ public Set<PhysicalTable> filter( Collection<PhysicalTable> candidateTables, List<PhysicalTableMatcher> matchers ) throws NoMatchFoundException { Collection<PhysicalTable> currentMatches = candidateTables; for (PhysicalTableMatcher matcher : matchers) { currentMatches = matcher.matchNotEmpty(currentMatches.stream()); } return new LinkedHashSet<>(currentMatches); }