Skip to content

Commit

Permalink
ref[protocol]: refactor field method
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Jul 15, 2024
1 parent 12c5a2d commit 0624228
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ private String protocol_field_definition(ProtocolRegistration registration) {
for (var fieldNote : fieldNotes) {
phpBuilder.append(fieldNote).append(LS);
}
var pair = phpSerializer(fieldRegistration.serializer()).fieldTypeDefaultValue(field, fieldRegistration);
phpBuilder.append(StringUtils.format("var {} ${} = {};", pair.getKey(), fieldName, pair.getValue())).append(LS);
var fieldTypeDefaultValue = phpSerializer(fieldRegistration.serializer()).fieldTypeDefaultValue(field, fieldRegistration);
var fieldType = fieldTypeDefaultValue.getKey();
var fieldDefaultValue = fieldTypeDefaultValue.getValue();
phpBuilder.append(StringUtils.format("var {} ${} = {};", fieldType, fieldName, fieldDefaultValue)).append(LS);
}
return phpBuilder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,10 @@ private String protocol_field_definition(ProtocolRegistration registration) {
for (var fieldNote : fieldNotes) {
scalaBuilder.append(fieldNote).append(LS);
}
var pair = scalaSerializer(fieldRegistration.serializer()).fieldTypeDefaultValue(field, fieldRegistration);
scalaBuilder.append(StringUtils.format("var {}: {} = {}", fieldName, pair.getKey(), pair.getValue())).append(LS);
var fieldTypeDefaultValue = scalaSerializer(fieldRegistration.serializer()).fieldTypeDefaultValue(field, fieldRegistration);
var fieldType = fieldTypeDefaultValue.getKey();
var fieldDefaultValue = fieldTypeDefaultValue.getValue();
scalaBuilder.append(StringUtils.format("var {}: {} = {}", fieldName, fieldType, fieldDefaultValue)).append(LS);
}
return scalaBuilder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,10 @@ private String protocol_field_definition(ProtocolRegistration registration) {
for (var fieldNote : fieldNotes) {
tsBuilder.append(fieldNote).append(LS);
}
var pair = tsSerializer(fieldRegistration.serializer()).fieldTypeDefaultValue(field, fieldRegistration);
tsBuilder.append(StringUtils.format("{}: {} = {};", fieldName, pair.getKey(), pair.getValue())).append(LS);
var fieldTypeDefaultValue = tsSerializer(fieldRegistration.serializer()).fieldTypeDefaultValue(field, fieldRegistration);
var fieldType = fieldTypeDefaultValue.getKey();
var fieldDefaultValue = fieldTypeDefaultValue.getValue();
tsBuilder.append(StringUtils.format("{}: {} = {};", fieldName, fieldType, fieldDefaultValue)).append(LS);
}
return tsBuilder.toString();
}
Expand Down

0 comments on commit 0624228

Please sign in to comment.