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;
    }
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
document/src/main/java/com/yahoo/document/datatypes/StructuredFieldValue.java