@Test public void testConstructor_Scale_Types() { System.out.println("NumberField(int, Types)"); for (Types type : Types.values()) { try { new NumberField(1, type); if (!isNumberType(type)) { fail("Incorrectly accepted " + type.getType() + " as a valid number type"); } } catch (OperationException ex) { if (isNumberType(type) && !typeTakesScale(type)) { assertEquals(ErrorCode.DATATYPE_ERROR, ex.getErrorCode()); } else if (isNumberType(type)) { fail("Incorrectly reported " + type.getType() + " as an invalid number type"); } } if (!typeTakesScale(type)) { continue; } for (int i = -84; i <= 127; i++) { try { new NumberField(i, type); } catch (OperationException ex) { fail("Failed to accept " + i + " as a valid scale value for type " + type.getType()); } } try { new NumberField(-85, type); fail("Accepted -85 as a valid scale value, when minimum permissible scale value is -84"); } catch (OperationException ex) { assertEquals(ErrorCode.DATATYPE_ERROR, ex.getErrorCode()); } try { new NumberField(128, type); fail("Accepted 128 as a valid scale value, when maximum permissible scale value 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();  }