Doubles { public static Double parse(final String s) { Double parsed = null; try { if (s != null) { parsed = Double.parseDouble(s); } } catch (final NumberFormatException e) { } return parsed; } private  Doubles(); static Double parse(final String s);  }
@Test public void testParse() { final String nullString = null; final String emptyString = null; final String integerString = "1"; final String decimalString = "1.0"; assertThat(Doubles.parse(nullString), is(nullValue())); assertThat(Doubles.parse(emptyString), is(nullValue())); assertThat(Doubles.parse(integerString), is(1.0)); assertThat(Doubles.parse(decimalString), is(1.0)); }