@Test public void testNotAllowingMissingValues() { final NumericValueSchema valueSchema = new NumericValueSchema(false); assertFalse("Missing value should not be valid if specified", valueSchema.validate(AbstractValueSchema.MISSING_VALUE)); assertFalse("Validation of a null value should not be allowed", valueSchema.validate(null)); assertFalse("Non numeric value should not be valid", valueSchema.validate("not a number")); assertTrue("Numeric value should be valid", valueSchema.validate("42")); }
@Override public boolean validate(final String value) { if (!super.validate(value)) { return false; } if (value == null) { return true; } try { Double.valueOf(value); return true; } catch (final NumberFormatException e) { return false; } }
NumericValueSchema extends AbstractValueSchema { @Override public boolean validate(final String value) { if (!super.validate(value)) { return false; } if (value == null) { return true; } try { Double.valueOf(value); return true; } catch (final NumberFormatException e) { return false; } } }
NumericValueSchema extends AbstractValueSchema { @Override public boolean validate(final String value) { if (!super.validate(value)) { return false; } if (value == null) { return true; } try { Double.valueOf(value); return true; } catch (final NumberFormatException e) { return false; } } NumericValueSchema(final boolean allowMissing); }
NumericValueSchema extends AbstractValueSchema { @Override public boolean validate(final String value) { if (!super.validate(value)) { return false; } if (value == null) { return true; } try { Double.valueOf(value); return true; } catch (final NumberFormatException e) { return false; } } NumericValueSchema(final boolean allowMissing); @Override boolean validate(final String value); }
NumericValueSchema extends AbstractValueSchema { @Override public boolean validate(final String value) { if (!super.validate(value)) { return false; } if (value == null) { return true; } try { Double.valueOf(value); return true; } catch (final NumberFormatException e) { return false; } } NumericValueSchema(final boolean allowMissing); @Override boolean validate(final String value);  }