Skip to content

Commit

Permalink
Apply review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow-Devil committed Oct 23, 2024
1 parent 3cdcde9 commit 66f7b52
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private static void updateRecordFields(JsonObject jsonObject, Map<String, JsonEl
TypeDescriptorNode node1 = (TypeDescriptorNode) entry.getValue().getKey().typeName();
TypeDescriptorNode node2 = (TypeDescriptorNode) entry.getValue().getValue().typeName();

TypeDescriptorNode nonJSONDataNode = null;
TypeDescriptorNode nonJsonDataNode = null;
IdentifierToken optionalFieldName = null;
boolean alreadyOptionalTypeDesc = false;

Expand All @@ -411,12 +411,12 @@ private static void updateRecordFields(JsonObject jsonObject, Map<String, JsonEl
} else if ((node1.kind().equals(SyntaxKind.JSON_KEYWORD) ||
node2.kind().equals(SyntaxKind.JSON_KEYWORD))) {
if (isNullAsOptional) {
nonJSONDataNode = NodeParser.parseTypeDescriptor(node1.kind().equals(SyntaxKind.JSON_KEYWORD)
nonJsonDataNode = NodeParser.parseTypeDescriptor(node1.kind().equals(SyntaxKind.JSON_KEYWORD)
? node2.toSourceCode() : node1.toSourceCode());
optionalFieldName = AbstractNodeFactory.createIdentifierToken(entry.getKey() +
SyntaxKind.QUESTION_MARK_TOKEN.stringValue());
} else {
nonJSONDataNode = NodeParser.parseTypeDescriptor(node1.kind().equals(SyntaxKind.JSON_KEYWORD)
nonJsonDataNode = NodeParser.parseTypeDescriptor(node1.kind().equals(SyntaxKind.JSON_KEYWORD)
? node2.toSourceCode() + SyntaxKind.QUESTION_MARK_TOKEN.stringValue() :
node1.toSourceCode() + SyntaxKind.QUESTION_MARK_TOKEN.stringValue());
}
Expand All @@ -430,7 +430,7 @@ private static void updateRecordFields(JsonObject jsonObject, Map<String, JsonEl
RecordFieldNode recordField =
(RecordFieldNode) getRecordField(jsonEntry, existingFieldNames, updatedFieldNames, isOptional);
recordField = recordField.modify()
.withTypeName(nonJSONDataNode == null ? unionTypeDescNode : nonJSONDataNode)
.withTypeName(nonJsonDataNode == null ? unionTypeDescNode : nonJsonDataNode)
.withFieldName(optionalFieldName == null ? recordField.fieldName() : optionalFieldName)
.apply();
recordFields.add(recordField);
Expand Down

0 comments on commit 66f7b52

Please sign in to comment.