Skip to content

Commit

Permalink
re review comments: clarify comments in format switch statements
Browse files Browse the repository at this point in the history
  • Loading branch information
vchudnov-g committed Oct 10, 2024
1 parent f2db138 commit a98d248
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,11 @@ private Field schemaToField(Schema sch, boolean optional, String debugPreviousPa
if (sch.format() == Format.LISTVALUE) {
valueType = Message.PRIMITIVES.get("google.protobuf.ListValue");
this.usesStructProto = true;
// the repeated semantics are inherent in the ListValue proto field type.
// Since the `google.prootbuf.ListValue` whence this schema was generated is JSON-encoded
// as an array (see https://protobuf.dev/programming-guides/proto3/#json), the Discovery
// file describes the JSON array items. However, since we want to encode this schema back
// as an opaque `google.protobuf.ListValue` (which has the`repeated` semantics embedded
// internally), we should not make this field `repeated`.
} else {
repeated = true;
}
Expand All @@ -576,7 +580,7 @@ private Field schemaToField(Schema sch, boolean optional, String debugPreviousPa
case INTEGER:
switch (sch.format()) {
case EMPTY:
// intentional fall-through
// intentional fall-through: if there's no format, we default to `int32`.
case INT32:
valueType = Message.PRIMITIVES.get("int32");
break;
Expand Down Expand Up @@ -605,7 +609,7 @@ private Field schemaToField(Schema sch, boolean optional, String debugPreviousPa
case NUMBER:
switch (sch.format()) {
case EMPTY:
// intentional fall-through
// intentional fall-through: if there's no format, we default to `float`.
case FLOAT:
valueType = Message.PRIMITIVES.get("float");
break;
Expand Down

0 comments on commit a98d248

Please sign in to comment.