NumberParserUtils { public static float getAsFloat(@Nullable Object in, float defaultValue) { if (in == null) { return defaultValue; } if (in instanceof Number) { return ((Number) in).floatValue(); } return (float) parseDouble(in.toString(), defaultValue); } private  NumberParserUtils(); static float getAsFloat(@Nullable Object in, float defaultValue); static float getAsFloat(@Nullable Map<String, ?> imgDetails, @Nullable String key, float defaultValue); static int getAsInt(@Nullable Map<String, ?> imgDetails, @Nullable String key, int defaultValue); static int getAsInt(@Nullable Object in, int defaultValue);  }
@Test public void getAsFloat_inIsNull() { assertThat(NumberParserUtils.getAsFloat(null, DEFAULT_FLOAT)).isWithin(0.0f).of(DEFAULT_FLOAT); }
@Test public void getAsFloat_inIsInt() { assertThat(NumberParserUtils.getAsFloat(3, DEFAULT_FLOAT)).isWithin(0.0f).of(3.0f); }
@Test public void getAsFloat_inIsStringNumber() { assertThat(NumberParserUtils.getAsFloat("3", DEFAULT_FLOAT)).isWithin(0.0f).of(3.0f); }
@Test public void getAsFloat_inIsStringChar() { assertThat(NumberParserUtils.getAsFloat("a", DEFAULT_FLOAT)).isWithin(0.0f).of(DEFAULT_FLOAT); }
@Test public void getAsFloat_inIsStringBlank() { assertThat(NumberParserUtils.getAsFloat(" ", DEFAULT_FLOAT)).isWithin(0.0f).of(DEFAULT_FLOAT); }