PercentageLongConverter extends GroupingStringToLongConverter { @Override public Result<Long> convertToModel(String value, ValueContext context) { value = value == null ? null : value.replace("%", ""); return super.convertToModel(value, context); } PercentageLongConverter(String message, boolean useGrouping); @Override String convertToPresentation(Long value, ValueContext context); @Override Result<Long> convertToModel(String value, ValueContext context);  }
@Test public void testConvertToModel() { PercentageLongConverter cv = new PercentageLongConverter("message", true); assertNull(cv.convertToModel(null, createContext()).getOrThrow(r -> new OCSRuntimeException())); Result<Long> result = cv.convertToModel("4%", createContext()); assertEquals(4L, result.getOrThrow(r -> new OCSRuntimeException()).longValue()); result = cv.convertToModel("4", createContext()); assertEquals(4L, result.getOrThrow(r -> new OCSRuntimeException()).longValue()); }