@@ -117,7 +117,8 @@ public ParsedUpdateData parseUpdateData(Map<String, Object> data) {
117
117
context .addToFieldMask (fieldPath );
118
118
} else {
119
119
@ Nullable
120
- FieldValue parsedValue = convertAndParseData (fieldValue , context .childContext (fieldPath ));
120
+ FieldValue parsedValue =
121
+ convertAndParseFieldData (fieldValue , context .childContext (fieldPath ));
121
122
if (parsedValue != null ) {
122
123
context .addToFieldMask (fieldPath );
123
124
updateData = updateData .set (fieldPath , parsedValue );
@@ -167,7 +168,8 @@ public ParsedUpdateData parseUpdateData(List<Object> fieldsAndValues) {
167
168
// Add it to the field mask, but don't add anything to updateData.
168
169
context .addToFieldMask (parsedField );
169
170
} else {
170
- FieldValue parsedValue = convertAndParseData (fieldValue , context .childContext (parsedField ));
171
+ FieldValue parsedValue =
172
+ convertAndParseFieldData (fieldValue , context .childContext (parsedField ));
171
173
if (parsedValue != null ) {
172
174
context .addToFieldMask (parsedField );
173
175
updateData = updateData .set (parsedField , parsedValue );
@@ -182,7 +184,7 @@ public ParsedUpdateData parseUpdateData(List<Object> fieldsAndValues) {
182
184
public FieldValue parseQueryValue (Object input ) {
183
185
ParseAccumulator accumulator = new ParseAccumulator (UserData .Source .Argument );
184
186
185
- @ Nullable FieldValue parsed = convertAndParseData (input , accumulator .rootContext ());
187
+ @ Nullable FieldValue parsed = convertAndParseFieldData (input , accumulator .rootContext ());
186
188
hardAssert (parsed != null , "Parsed data should not be null." );
187
189
hardAssert (
188
190
accumulator .getFieldTransforms ().isEmpty (),
@@ -191,14 +193,15 @@ public FieldValue parseQueryValue(Object input) {
191
193
}
192
194
193
195
/** Converts a POJO to native types and then parses it into model types. */
194
- private FieldValue convertAndParseData (Object input , ParseContext context ) {
196
+ private FieldValue convertAndParseFieldData (Object input , ParseContext context ) {
195
197
Object converted = CustomClassMapper .convertToPlainJavaTypes (input );
196
198
return parseData (converted , context );
197
199
}
198
200
199
201
/**
200
- * Wrapper around convertAndParseData() that expects input to conform to document data (in
201
- * particular, must decode into an ObjectValue).
202
+ * Converts a POJO to native types and then parses it into model types. It expects the input to
203
+ * conform to document data (i.e. it must parse into an ObjectValue model type) and will throw an
204
+ * appropriate error otherwise.
202
205
*/
203
206
private ObjectValue convertAndParseDocumentData (Object input , ParseContext context ) {
204
207
String badDocReason =
@@ -210,7 +213,8 @@ private ObjectValue convertAndParseDocumentData(Object input, ParseContext conte
210
213
throw new IllegalArgumentException (badDocReason + "an array" );
211
214
}
212
215
213
- FieldValue value = convertAndParseData (input , context );
216
+ Object converted = CustomClassMapper .convertToPlainJavaTypes (input );
217
+ FieldValue value = parseData (converted , context );
214
218
215
219
if (!(value instanceof ObjectValue )) {
216
220
throw new IllegalArgumentException (badDocReason + "of type: " + Util .typeName (input ));
@@ -419,7 +423,7 @@ private List<FieldValue> parseArrayTransformElements(List<Object> elements) {
419
423
// being unioned or removed are not considered writes since they cannot
420
424
// contain any FieldValue sentinels, etc.
421
425
ParseContext context = accumulator .rootContext ();
422
- result .add (convertAndParseData (element , context .childContext (i )));
426
+ result .add (convertAndParseFieldData (element , context .childContext (i )));
423
427
}
424
428
return result ;
425
429
}
0 commit comments