GenericNameVersion extends AbstractNameVersion { public static GenericNameVersion ofFirst(CharSequence string) { Matcher matcher = NAME_VERSION_PATTERN.matcher(string); if (matcher.find()) { return ofMatcher(matcher); } return null; } GenericNameVersion(String name, String version); @Override String getName(); GenericNameVersion withVersion(String newVersion); GenericNameVersion withName(String newName); @Override int hashCode(); @Override boolean equals(Object obj); static List<? extends GenericNameVersion> ofAll(CharSequence string); static GenericNameVersion of(CharSequence string); static GenericNameVersion ofFirst(CharSequence string); static GenericNameVersion ofMatcher(Matcher matcher); static String toString(NameVersion... nameVersions);  }
@Test public void testOfFirst() { assertThat(GenericNameVersion.ofFirst(MOZILLA_NVC)).isEqualTo(MOZILLA); assertThat(GenericNameVersion.ofFirst(WEBKIT_NVC)).isEqualTo(WEBKIT); assertThat(GenericNameVersion.ofFirst(VERSION_NV)).isEqualTo(VERSION); assertThat(GenericNameVersion.ofFirst(SAFARI_NV)).isEqualTo(SAFARI); assertThat(GenericNameVersion.ofFirst(DEBIAN_NVC)).isEqualTo(DEBIAN); assertThat(GenericNameVersion.ofFirst(EPIPHANY_NV)).isEqualTo(EPIPHANY); assertThat(GenericNameVersion.ofFirst(ALL)).isEqualTo(MOZILLA); assertThat(GenericNameVersion.ofFirst(DEBIAN_NVC + " " + ALL)).isEqualTo(DEBIAN); assertThat(GenericNameVersion.ofFirst("")).isNull(); assertThat(GenericNameVersion.ofFirst("hello world")).isNull(); }