@Test @Parameters({ "0, 0", "0.0, 0", "1-asdasdsad, 1", "1-asdasdsad2, 1", "12-asdasdsad2, 12", }) public void shouldParseIfHasNumber(String version, String result) { double resultCode = VersionParser.toDouble(version); assertThat(resultCode, Is.is(Double.valueOf(result))); }
public static double toDouble(String version) { if (version != null) { try { return Double.parseDouble(version); } catch (NumberFormatException ex) { if (version.contains(".")) { return parseAsVersionName(version); } else { return parseAsNumber(version); } } } return INVALID_VERSION; }
VersionParser { public static double toDouble(String version) { if (version != null) { try { return Double.parseDouble(version); } catch (NumberFormatException ex) { if (version.contains(".")) { return parseAsVersionName(version); } else { return parseAsNumber(version); } } } return INVALID_VERSION; } }
VersionParser { public static double toDouble(String version) { if (version != null) { try { return Double.parseDouble(version); } catch (NumberFormatException ex) { if (version.contains(".")) { return parseAsVersionName(version); } else { return parseAsNumber(version); } } } return INVALID_VERSION; } private  VersionParser(); }
VersionParser { public static double toDouble(String version) { if (version != null) { try { return Double.parseDouble(version); } catch (NumberFormatException ex) { if (version.contains(".")) { return parseAsVersionName(version); } else { return parseAsNumber(version); } } } return INVALID_VERSION; } private  VersionParser(); static double toDouble(String version); }
VersionParser { public static double toDouble(String version) { if (version != null) { try { return Double.parseDouble(version); } catch (NumberFormatException ex) { if (version.contains(".")) { return parseAsVersionName(version); } else { return parseAsNumber(version); } } } return INVALID_VERSION; } private  VersionParser(); static double toDouble(String version);  }