NumericIntegerTextBox extends AbstractRestrictedEntryTextBox { @Override public boolean isValidValue(final String value, final boolean isOnFocusLost) { boolean isValid = VALID.test(value); if (!isValid) { return isValid; } if (!isOnFocusLost && "-".equals(value)) { return true; } try { Integer.parseInt(value); } catch (NumberFormatException nfe) { isValid = ("".equals(value) && allowEmptyValue); } return isValid; } NumericIntegerTextBox();  NumericIntegerTextBox(final boolean allowEmptyValue); @Override boolean isValidValue(final String value,
                                final boolean isOnFocusLost);  }
@Test public void testIsValidValue_ValidValues() { Assertions.assertThat(numericIntegerTextBox.isValidValue("123", false)).isTrue(); Assertions.assertThat(numericIntegerTextBox.isValidValue("-123", false)).isTrue(); }
@Test public void testIsValidValue_InvalidValues() { Assertions.assertThat(numericIntegerTextBox.isValidValue("123.0", false)).isFalse(); Assertions.assertThat(numericIntegerTextBox.isValidValue("abcd", false)).isFalse(); Assertions.assertThat(numericIntegerTextBox.isValidValue("!", false)).isFalse(); }