Extension implements Deliverable { static String removePattern(Pattern pattern, String string) { Matcher matcher = pattern.matcher(string); if (matcher.matches()) { return matcher.group(1); } return string; } @JsonCreator  Extension(@JsonProperty("id") String id,
                  @JsonProperty("name") String name,
                  @JsonProperty("version") String version,
                  @JsonProperty("description") String description,
                  @JsonProperty("url") URL url,
                  @JsonProperty("type") Type type);   Extension(URL url, Type type);   Extension(URL url); @Override File download(); void install(Path extensionsDir); @Override void install(File extensionFile, Path extensionsDir); @Override void delete(Path installDir); @Override URL getUrl(); @Override String getId(); @Override String getName(); @Override String getDescription(); @Override String getVersion(); @Override Type getType(); Path getBasePath(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final String TMP_PREFIX; final String id; final String name; final String description; final URL url; final String version; final Type type; }
@Test public void test_remove_pattern() { assertThat(Extension.removePattern(Extension.endsWithVersion,"my-extension")).isEqualTo("my-extension"); assertThat(Extension.removePattern(Extension.endsWithVersion,"my-extension-1.2.3")).isEqualTo("my-extension"); assertThat(Extension.removePattern(Extension.endsWithVersion,"extension.with.dot-1.0.0")).isEqualTo("extension.with.dot"); assertThat(Extension.removePattern(Extension.endsWithExtension,"my-extension")).isEqualTo("my-extension"); assertThat(Extension.removePattern(Extension.endsWithExtension,"my-extension.jar")).isEqualTo("my-extension"); assertThat(Extension.removePattern(Extension.endsWithExtension,"my-extension-1.2.3")).isEqualTo("my-extension-1.2.3"); }