IgnoreMissingValuesConverter implements ITypeConverter<TTargetType> { @Override public TTargetType convert(final String s) { if(StringUtils.isNullOrWhiteSpace(s)) { return null; } boolean isMissingValue = missingValueRepresentation .stream() .anyMatch(x -> x.equals(s)); if(isMissingValue) { return null; } return converter.convert(s); } IgnoreMissingValuesConverter(ITypeConverter<TTargetType> converter, String... missingValueRepresentation);  IgnoreMissingValuesConverter(ITypeConverter<TTargetType> converter, List<String> missingValueRepresentation); @Override TTargetType convert(final String s); @Override Type getTargetType();  }
@Test public void testConvertWithDefaultConstructor() throws Exception { IgnoreMissingValuesConverter<Float> floatConverter = new IgnoreMissingValuesConverter<>(new FloatConverter()); Assert.assertEquals(null, floatConverter.convert(null)); Assert.assertEquals(null, floatConverter.convert("")); }
@Test public void testConvertWithCustomValues() throws Exception { IgnoreMissingValuesConverter<Float> floatConverter = new IgnoreMissingValuesConverter<>(new FloatConverter(), "M", "A"); Assert.assertEquals(null, floatConverter.convert(null)); Assert.assertEquals(null, floatConverter.convert("")); Assert.assertEquals(null, floatConverter.convert("M")); Assert.assertEquals(null, floatConverter.convert("A")); }