/** * Sets the value of the given field. The type of the value must match the type of this field, i.e. * <pre>field.getDataType().getValueClass().isAssignableFrom(value.getClass())</pre> must be true. * * @param field The field whose value to set. * @param value The value to set. * @return The previous value of the field, or null. * @throws IllegalArgumentException If the value is not compatible with the field. */ public FieldValue setFieldValue(Field field, FieldValue value) { if (value == null) { return removeFieldValue(field); } DataType type = field.getDataType(); if (!type.getValueClass().isAssignableFrom(value.getClass())) { FieldValue tmp = type.createFieldValue(); tmp.assign(value); value = tmp; } FieldValue ret = getFieldValue(field); doSetFieldValue(field, value); return ret; }