/** * Run matches on each physical table in the stream, filtering down to matching tables. * * @param tables A stream of tables to match on * * @return Any tables which match the criteria from {@link #test(PhysicalTable)} * @throws NoMatchFoundException if no tables in the stream match */ default Set<PhysicalTable> matchNotEmpty(Stream<PhysicalTable> tables) throws NoMatchFoundException { Set<PhysicalTable> result = tables .filter(this) .collect(Collectors.toCollection(LinkedHashSet::new)); if (result.isEmpty()) { throw noneFoundException(); } return result; } }