@Test void testFilterEnd() { final CodestartFileStrategy strategy = new CodestartFileStrategy("/foo/bar/*", mock(CodestartFileStrategyHandler.class)); assertThat(strategy.test("/foo/bar/myfile.txt")).isTrue(); assertThat(strategy.test("/foo/bar/baz/anoter_file")).isTrue(); assertThat(strategy.test(null)).isFalse(); assertThat(strategy.test("foo/bar/myfile.txt")).isFalse(); assertThat(strategy.test("something")).isFalse(); assertThat(strategy.test("")).isFalse(); }
@Override public boolean test(String t) { if (t == null) { return false; } if (filter.startsWith("*") && filter.length() > 1) { if (t.endsWith(filter.substring(1))) { return true; } } if (filter.endsWith("*") && filter.length() > 1) { if (t.startsWith(filter.substring(0, filter.length() - 1))) { return true; } } return filter.equals(t); }
CodestartFileStrategy implements Predicate<String> { @Override public boolean test(String t) { if (t == null) { return false; } if (filter.startsWith("*") && filter.length() > 1) { if (t.endsWith(filter.substring(1))) { return true; } } if (filter.endsWith("*") && filter.length() > 1) { if (t.startsWith(filter.substring(0, filter.length() - 1))) { return true; } } return filter.equals(t); } }
CodestartFileStrategy implements Predicate<String> { @Override public boolean test(String t) { if (t == null) { return false; } if (filter.startsWith("*") && filter.length() > 1) { if (t.endsWith(filter.substring(1))) { return true; } } if (filter.endsWith("*") && filter.length() > 1) { if (t.startsWith(filter.substring(0, filter.length() - 1))) { return true; } } return filter.equals(t); } CodestartFileStrategy(String filter, CodestartFileStrategyHandler handler); }
CodestartFileStrategy implements Predicate<String> { @Override public boolean test(String t) { if (t == null) { return false; } if (filter.startsWith("*") && filter.length() > 1) { if (t.endsWith(filter.substring(1))) { return true; } } if (filter.endsWith("*") && filter.length() > 1) { if (t.startsWith(filter.substring(0, filter.length() - 1))) { return true; } } return filter.equals(t); } CodestartFileStrategy(String filter, CodestartFileStrategyHandler handler); String getFilter(); @Override boolean test(String t); CodestartFileStrategyHandler getHandler(); @Override String toString(); }
CodestartFileStrategy implements Predicate<String> { @Override public boolean test(String t) { if (t == null) { return false; } if (filter.startsWith("*") && filter.length() > 1) { if (t.endsWith(filter.substring(1))) { return true; } } if (filter.endsWith("*") && filter.length() > 1) { if (t.startsWith(filter.substring(0, filter.length() - 1))) { return true; } } return filter.equals(t); } CodestartFileStrategy(String filter, CodestartFileStrategyHandler handler); String getFilter(); @Override boolean test(String t); CodestartFileStrategyHandler getHandler(); @Override String toString();  }