IgnoreMissingValuesConverter implements ITypeConverter<Float> { @Override public Float convert(final String s) { if(StringUtils.isNullOrWhiteSpace(s)) { return null; } boolean isMissingValue = missingValueRepresentation .stream() .anyMatch(x -> x.equals(s)); if(isMissingValue) { return null; } return Float.parseFloat(s); } IgnoreMissingValuesConverter(String... missingValueRepresentation);  IgnoreMissingValuesConverter(List<String> missingValueRepresentation); @Override Float convert(final String s); @Override Type getTargetType();  }
@Test public void returns_null_if_value_is_missing() throws Exception { IgnoreMissingValuesConverter converter = new IgnoreMissingValuesConverter("M", "m"); Assert.assertEquals(null, converter.convert("")); Assert.assertEquals(null, converter.convert("M")); Assert.assertEquals(null, converter.convert("m")); Assert.assertEquals(1.0f, converter.convert("1.0"), 1e-3); }