@Test public void testConstructor_Types_Default() throws OperationException { System.out.println("NumberField(Types,Number)"); for (Types type : Types.values()) { try { new NumberField(type, new Integer(0)); if (!isNumberType(type)) { fail("Incorrectly accepted " + type.getType() + " as a valid number type"); } } catch (OperationException ex) { if (ex.getErrorCode() != ErrorCode.DATATYPE_MISMATCH) { fail("Incorrect error code reported for data type mismatch"); } if (isNumberType(type)) { fail("Incorrectly reported " + type.getType() + " as an invalid number type"); } } if (!isNumberType(type)) { continue; } switch (type) { case SMALLINT: new NumberField(type, new Short((short) -1)); new NumberField(type, new Short((short) 0)); new NumberField(type, new Short((short) 1)); break; case INTEGER: case INT: new NumberField(type, new Integer(-1)); new NumberField(type, new Integer(0)); new NumberField(type, new Integer(1)); break; case LONG: case BIGINT: new NumberField(type, new Long(1)); new NumberField(type, new Long(0)); new NumberField(type, new Long(1)); break; case DOUBLE: case DOUBLE_PRECISION: new NumberField(type, new Double(-1.1)); new NumberField(type, new Double(0.0)); new NumberField(type, new Double(1.1)); break; case REAL: case FLOAT: new NumberField(type, new Float(-1.1)); new NumberField(type, new Float(0.0)); new NumberField(type, new Float(1.1)); break; case NUMERIC: case DECIMAL: case DEC: new NumberField(type, new Short((short) -1)); new NumberField(type, new Short((short) 0)); new NumberField(type, new Short((short) 1)); new NumberField(type, new Integer(-1)); new NumberField(type, new Integer(0)); new NumberField(type, new Integer(1)); new NumberField(type, new Long(1)); new NumberField(type, new Long(0)); new NumberField(type, new Long(1)); new NumberField(type, new Double(-1.1)); new NumberField(type, new Double(0.0)); new NumberField(type, new Double(1.1)); new NumberField(type, new Float(-1.1)); new NumberField(type, new Float(0.0)); new NumberField(type, new Float(1.1)); break; } switch (type) { case SMALLINT: case INTEGER: case INT: case LONG: case BIGINT: try { new NumberField(type, new Double(-1.1)); } catch (OperationException ex) { fail("Failed to approximate a floating point type to a non floating point number " + type.getType()); } try { new NumberField(type, new Double(0.0)); } catch (OperationException ex) { fail("Failed to approximate a floating point type to a non floating point number " + type.getType()); } try { new NumberField(type, new Double(1.1)); } catch (OperationException ex) { } try { new NumberField(type, new Float(-1.1)); } catch (OperationException ex) { fail("Failed to approximate a floating point type to a non floating point number " + type.getType()); } try { new NumberField(type, new Float(0.0)); } catch (OperationException ex) { fail("Failed to approximate a floating point type to a non floating point number " + type.getType()); } try { new NumberField(type, new Float(1.1)); } catch (OperationException ex) { fail("Failed to approximate a floating point type to a non floating point number " + type.getType()); } break; case DOUBLE: case DOUBLE_PRECISION: case REAL: case FLOAT: case NUMERIC: case DECIMAL: case DEC: break; } } }
@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();  }