Skip to content

Commit 8500dd8

Browse files
author
Michael Lehenbauer
committed
CR feedback: convertAndParseData() => convertAndParseFielData().
1 parent 08b37c1 commit 8500dd8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataConverter.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ public ParsedUpdateData parseUpdateData(Map<String, Object> data) {
117117
context.addToFieldMask(fieldPath);
118118
} else {
119119
@Nullable
120-
FieldValue parsedValue = convertAndParseData(fieldValue, context.childContext(fieldPath));
120+
FieldValue parsedValue =
121+
convertAndParseFieldData(fieldValue, context.childContext(fieldPath));
121122
if (parsedValue != null) {
122123
context.addToFieldMask(fieldPath);
123124
updateData = updateData.set(fieldPath, parsedValue);
@@ -167,7 +168,8 @@ public ParsedUpdateData parseUpdateData(List<Object> fieldsAndValues) {
167168
// Add it to the field mask, but don't add anything to updateData.
168169
context.addToFieldMask(parsedField);
169170
} else {
170-
FieldValue parsedValue = convertAndParseData(fieldValue, context.childContext(parsedField));
171+
FieldValue parsedValue =
172+
convertAndParseFieldData(fieldValue, context.childContext(parsedField));
171173
if (parsedValue != null) {
172174
context.addToFieldMask(parsedField);
173175
updateData = updateData.set(parsedField, parsedValue);
@@ -182,7 +184,7 @@ public ParsedUpdateData parseUpdateData(List<Object> fieldsAndValues) {
182184
public FieldValue parseQueryValue(Object input) {
183185
ParseAccumulator accumulator = new ParseAccumulator(UserData.Source.Argument);
184186

185-
@Nullable FieldValue parsed = convertAndParseData(input, accumulator.rootContext());
187+
@Nullable FieldValue parsed = convertAndParseFieldData(input, accumulator.rootContext());
186188
hardAssert(parsed != null, "Parsed data should not be null.");
187189
hardAssert(
188190
accumulator.getFieldTransforms().isEmpty(),
@@ -191,14 +193,15 @@ public FieldValue parseQueryValue(Object input) {
191193
}
192194

193195
/** 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) {
195197
Object converted = CustomClassMapper.convertToPlainJavaTypes(input);
196198
return parseData(converted, context);
197199
}
198200

199201
/**
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.
202205
*/
203206
private ObjectValue convertAndParseDocumentData(Object input, ParseContext context) {
204207
String badDocReason =
@@ -210,7 +213,8 @@ private ObjectValue convertAndParseDocumentData(Object input, ParseContext conte
210213
throw new IllegalArgumentException(badDocReason + "an array");
211214
}
212215

213-
FieldValue value = convertAndParseData(input, context);
216+
Object converted = CustomClassMapper.convertToPlainJavaTypes(input);
217+
FieldValue value = parseData(converted, context);
214218

215219
if (!(value instanceof ObjectValue)) {
216220
throw new IllegalArgumentException(badDocReason + "of type: " + Util.typeName(input));
@@ -419,7 +423,7 @@ private List<FieldValue> parseArrayTransformElements(List<Object> elements) {
419423
// being unioned or removed are not considered writes since they cannot
420424
// contain any FieldValue sentinels, etc.
421425
ParseContext context = accumulator.rootContext();
422-
result.add(convertAndParseData(element, context.childContext(i)));
426+
result.add(convertAndParseFieldData(element, context.childContext(i)));
423427
}
424428
return result;
425429
}

0 commit comments

Comments
 (0)