@Test public void testConstructor_Types_Precision() throws OperationException { System.out.println("NumberField(Types)"); for (Types type : Types.values()) { try { new NumberField(type, 1); if (!isNumberType(type)) { fail("Incorrectly accepted " + type.getType() + " as a valid number type"); } } catch (OperationException ex) { if (isNumberType(type) && !typeTakesPrecision(type)) { assertEquals(ErrorCode.DATATYPE_ERROR, ex.getErrorCode()); } else if (isNumberType(type)) { fail("Incorrectly reported " + type.getType() + " as an invalid number type"); } } if (!isNumberType(type) || !typeTakesPrecision(type)) { continue; } for (int i = 1; i <= (type == Types.FLOAT ? 24 : 127); i++) { new NumberField(type, i); } try { new NumberField(type, 0); fail("Number type accepted value with precision of 0, where as precision has to be greater than or equal to one"); } catch (OperationException ex) { assertEquals(ErrorCode.DATATYPE_ERROR, ex.getErrorCode()); } try { new NumberField(type, -1); fail("Number type accepted value with precision of -1, where as precision has to be greater than or equal to one"); } catch (OperationException ex) { assertEquals(ErrorCode.DATATYPE_ERROR, ex.getErrorCode()); } try { new NumberField(type, 128); fail("Number type accepted value with precision of 128, where as maximum permitted value for precision is 127"); } catch (OperationException ex) { assertEquals(ErrorCode.DATATYPE_ERROR, ex.getErrorCode()); } } }
@Override public Types getType() { return type; }
NumberField implements FieldType<Number> { @Override public Types getType() { return type; } }
NumberField implements FieldType<Number> { @Override public Types getType() { return type; } NumberField(final Types type);  NumberField(final Types type, final Number defaultValue);  NumberField(final Types type, final int precision);  NumberField(final int scale, final Types type);  NumberField(final Types type, final int precision, final Number defaultValue);  NumberField(final int scale, final Types type, final Number defaultValue);  NumberField(final Types type, final int precision, final int scale);  NumberField(final Types type, final int precision, final int scale, final Number defaultValue); }
NumberField implements FieldType<Number> { @Override public Types getType() { return type; } NumberField(final Types type);  NumberField(final Types type, final Number defaultValue);  NumberField(final Types type, final int precision);  NumberField(final int scale, final Types type);  NumberField(final Types type, final int precision, final Number defaultValue);  NumberField(final int scale, final Types type, final Number defaultValue);  NumberField(final Types type, final int precision, final int scale);  NumberField(final Types type, final int precision, final int scale, final Number defaultValue); @Override Types getType(); int getPrecision(); Integer getScale(); @Override Number getDefaultValue(); @Override boolean hasDefaultValue(); @Override Number convert(Object objValue); @Override JSONObject toJson(); }
NumberField implements FieldType<Number> { @Override public Types getType() { return type; } NumberField(final Types type);  NumberField(final Types type, final Number defaultValue);  NumberField(final Types type, final int precision);  NumberField(final int scale, final Types type);  NumberField(final Types type, final int precision, final Number defaultValue);  NumberField(final int scale, final Types type, final Number defaultValue);  NumberField(final Types type, final int precision, final int scale);  NumberField(final Types type, final int precision, final int scale, final Number defaultValue); @Override Types getType(); int getPrecision(); Integer getScale(); @Override Number getDefaultValue(); @Override boolean hasDefaultValue(); @Override Number convert(Object objValue); @Override JSONObject toJson();  }