@Test public void should_return_default_value_when_string_is_null() { assertThat(NumberUtils.toFloat(null, 0.0f)) .as("String parsed to float") .isEqualTo(0.0f, Offset.offset(0.01f)); }
public static float toFloat(final String str, final float defaultValue) { if (str == null) { return defaultValue; } try { return Float.parseFloat(str); } catch (final NumberFormatException nfe) { return defaultValue; } }
NumberUtils { public static float toFloat(final String str, final float defaultValue) { if (str == null) { return defaultValue; } try { return Float.parseFloat(str); } catch (final NumberFormatException nfe) { return defaultValue; } } }
NumberUtils { public static float toFloat(final String str, final float defaultValue) { if (str == null) { return defaultValue; } try { return Float.parseFloat(str); } catch (final NumberFormatException nfe) { return defaultValue; } }  }
NumberUtils { public static float toFloat(final String str, final float defaultValue) { if (str == null) { return defaultValue; } try { return Float.parseFloat(str); } catch (final NumberFormatException nfe) { return defaultValue; } }  static float toFloat(final String str, final float defaultValue); }
NumberUtils { public static float toFloat(final String str, final float defaultValue) { if (str == null) { return defaultValue; } try { return Float.parseFloat(str); } catch (final NumberFormatException nfe) { return defaultValue; } }  static float toFloat(final String str, final float defaultValue);  }