VfsTableModelFileNameRowFilter extends RowFilter<VfsTableModel, Integer> { boolean checkIfInclude(String baseName, String patternText) { Optional<Pattern> pattern = Optional.empty(); try { String patternString = preparePatternString(patternText); pattern = Optional.of(Pattern.compile(patternString)); } catch (PatternSyntaxException pse) { LOGGER.error(pse.getMessage()); } return StringUtils.containsIgnoreCase(baseName, patternText) || pattern.map(p -> p.matcher(baseName).matches()).orElse(false); } VfsTableModelFileNameRowFilter(JTextField textField); @Override boolean include(Entry<? extends VfsTableModel, ? extends Integer> entry);  }
@Test(dataProvider = "testCheckIfIncludeDataProvider") public void testCheckIfInclude(String baseName, String patternText, boolean expected) throws Exception { VfsTableModelFileNameRowFilter rowFilter = new VfsTableModelFileNameRowFilter(null); boolean result = rowFilter.checkIfInclude(baseName, patternText); Assert.assertEquals(result, expected, String.format("%s with pattern %s should be accepted: %s but result was %s", baseName, patternText, expected, result )); }