@Test public void equalsWithHashes() { Predicate<String> pred = MavenMatcherSupport.withHashes("/some-path.txt"::equals); assertThat(pred.apply("/some-path.txt"), equalTo(true)); assertThat(pred.apply("/some-path.txt.sha1"), equalTo(true)); assertThat(pred.apply("/some-path.txt.md5"), equalTo(true)); assertThat(pred.apply("some-path.txt"), equalTo(false)); assertThat(pred.apply("/some-path.txt.sha512"), equalTo(false)); assertThat(pred.apply("/some-path.txt.crc"), equalTo(false)); assertThat(pred.apply("/some-path.tx"), equalTo(false)); assertThat(pred.apply("/other-path.txt"), equalTo(false)); }
public static Predicate<String> withHashes(final Predicate<String> predicate) { return (String input) -> { String mainPath = input; for (HashType hashType : HashType.values()) { if (mainPath.endsWith("." + hashType.getExt())) { mainPath = mainPath.substring(0, mainPath.length() - (hashType.getExt().length() + 1)); break; } } return predicate.apply(mainPath); }; }
MavenMatcherSupport extends ComponentSupport implements Matcher { public static Predicate<String> withHashes(final Predicate<String> predicate) { return (String input) -> { String mainPath = input; for (HashType hashType : HashType.values()) { if (mainPath.endsWith("." + hashType.getExt())) { mainPath = mainPath.substring(0, mainPath.length() - (hashType.getExt().length() + 1)); break; } } return predicate.apply(mainPath); }; } }
MavenMatcherSupport extends ComponentSupport implements Matcher { public static Predicate<String> withHashes(final Predicate<String> predicate) { return (String input) -> { String mainPath = input; for (HashType hashType : HashType.values()) { if (mainPath.endsWith("." + hashType.getExt())) { mainPath = mainPath.substring(0, mainPath.length() - (hashType.getExt().length() + 1)); break; } } return predicate.apply(mainPath); }; } MavenMatcherSupport(final MavenPathParser mavenPathParser, final Predicate<String> predicate); }
MavenMatcherSupport extends ComponentSupport implements Matcher { public static Predicate<String> withHashes(final Predicate<String> predicate) { return (String input) -> { String mainPath = input; for (HashType hashType : HashType.values()) { if (mainPath.endsWith("." + hashType.getExt())) { mainPath = mainPath.substring(0, mainPath.length() - (hashType.getExt().length() + 1)); break; } } return predicate.apply(mainPath); }; } MavenMatcherSupport(final MavenPathParser mavenPathParser, final Predicate<String> predicate); static Predicate<String> withHashes(final Predicate<String> predicate); @Override boolean matches(final Context context); }
MavenMatcherSupport extends ComponentSupport implements Matcher { public static Predicate<String> withHashes(final Predicate<String> predicate) { return (String input) -> { String mainPath = input; for (HashType hashType : HashType.values()) { if (mainPath.endsWith("." + hashType.getExt())) { mainPath = mainPath.substring(0, mainPath.length() - (hashType.getExt().length() + 1)); break; } } return predicate.apply(mainPath); }; } MavenMatcherSupport(final MavenPathParser mavenPathParser, final Predicate<String> predicate); static Predicate<String> withHashes(final Predicate<String> predicate); @Override boolean matches(final Context context);  }