IvyVersionMatcher implements Predicate<String>, JsonSerializable { @NonNull public static IvyVersionMatcher newMatcher(@NonNull String constraint) { constraint = constraint.replaceAll(WHITESPACE, ""); Predicate<String> predicate = parseExactVersionConstraint(constraint); if (predicate != null) { return new IvyVersionMatcher(predicate, constraint); } predicate = parseSubVersionConstraint(constraint); if (predicate != null) { return new IvyVersionMatcher(predicate, constraint); } predicate = parseVersionRangeConstraint(constraint); if (predicate != null) { return new IvyVersionMatcher(predicate, constraint); } throw new IllegalArgumentException("Invalid constraint: " + constraint); } private  IvyVersionMatcher(Predicate<String> predicate, String constraint); @NonNull static IvyVersionMatcher newMatcher(@NonNull String constraint); @Override boolean apply(@Nullable String versionString); @NonNull @Override JsonValue toJsonValue(); @Override boolean equals(@Nullable Object o); @Override int hashCode();  }
@Test(expected = IllegalArgumentException.class) public void testEmptyConstraint() { IvyVersionMatcher.newMatcher(""); }
@Test(expected = IllegalArgumentException.class) public void testInvalidNumber() { IvyVersionMatcher.newMatcher("1.a"); }
@Test(expected = IllegalArgumentException.class) public void testInvalidVersion() { IvyVersionMatcher.newMatcher("1.2.3.4"); }
@Test(expected = IllegalArgumentException.class) public void testInfiniteStartRangeWithVersion() { IvyVersionMatcher.newMatcher("(1.0,2.0]"); }
@Test(expected = IllegalArgumentException.class) public void testInfiniteEndRangeWithVersion() { IvyVersionMatcher.newMatcher("[1.0,2.0)"); }
@Test(expected = IllegalArgumentException.class) public void testInvalidStartToken() { IvyVersionMatcher.newMatcher("),2.0]"); }
@Test(expected = IllegalArgumentException.class) public void testInvalidEndToken() { IvyVersionMatcher.newMatcher("[1.0,2.0("); }