@@ -446,100 +446,100 @@ func TestBuildQueryLines(t *testing.T) {
446446 // primitives
447447 {
448448 & api.Field {Name : "bool" , JSONName : "bool" , Typez : api .BOOL_TYPE },
449- []string {"if (result.bool$.isNotDefault) 'bool': '${result.bool$ }'" },
449+ []string {"if (result.bool$ case final $1 when $1 .isNotDefault) 'bool': '${$1 }'" },
450450 }, {
451451 & api.Field {Name : "int32" , JSONName : "int32" , Typez : api .INT32_TYPE },
452- []string {"if (result.int32.isNotDefault) 'int32': '${result.int32 }'" },
452+ []string {"if (result.int32 case final $1 when $1 .isNotDefault) 'int32': '${$1 }'" },
453453 }, {
454454 & api.Field {Name : "fixed32" , JSONName : "fixed32" , Typez : api .FIXED32_TYPE },
455- []string {"if (result.fixed32.isNotDefault) 'fixed32': '${result.fixed32 }'" },
455+ []string {"if (result.fixed32 case final $1 when $1 .isNotDefault) 'fixed32': '${$1 }'" },
456456 }, {
457457 & api.Field {Name : "sfixed32" , JSONName : "sfixed32" , Typez : api .SFIXED32_TYPE },
458- []string {"if (result.sfixed32.isNotDefault) 'sfixed32': '${result.sfixed32 }'" },
458+ []string {"if (result.sfixed32 case final $1 when $1 .isNotDefault) 'sfixed32': '${$1 }'" },
459459 }, {
460460 & api.Field {Name : "int64" , JSONName : "int64" , Typez : api .INT64_TYPE },
461- []string {"if (result.int64.isNotDefault) 'int64': '${result.int64 }'" },
461+ []string {"if (result.int64 case final $1 when $1 .isNotDefault) 'int64': '${$1 }'" },
462462 }, {
463463 & api.Field {Name : "fixed64" , JSONName : "fixed64" , Typez : api .FIXED64_TYPE },
464- []string {"if (result.fixed64.isNotDefault) 'fixed64': '${result.fixed64 }'" },
464+ []string {"if (result.fixed64 case final $1 when $1 .isNotDefault) 'fixed64': '${$1 }'" },
465465 }, {
466466 & api.Field {Name : "sfixed64" , JSONName : "sfixed64" , Typez : api .SFIXED64_TYPE },
467- []string {"if (result.sfixed64.isNotDefault) 'sfixed64': '${result.sfixed64 }'" },
467+ []string {"if (result.sfixed64 case final $1 when $1 .isNotDefault) 'sfixed64': '${$1 }'" },
468468 }, {
469469 & api.Field {Name : "double" , JSONName : "double" , Typez : api .DOUBLE_TYPE },
470- []string {"if (result.double$.isNotDefault) 'double': '${result.double$ }'" },
470+ []string {"if (result.double$ case final $1 when $1 .isNotDefault) 'double': '${$1 }'" },
471471 }, {
472472 & api.Field {Name : "string" , JSONName : "string" , Typez : api .STRING_TYPE },
473- []string {"if (result.string.isNotDefault) 'string': result.string " },
473+ []string {"if (result.string case final $1 when $1 .isNotDefault) 'string': $1 " },
474474 },
475475
476476 // optional primitives
477477 {
478478 & api.Field {Name : "bool_opt" , JSONName : "bool" , Typez : api .BOOL_TYPE , Optional : true },
479- []string {"if (result.boolOpt != null ) 'bool': '${result.boolOpt }'" },
479+ []string {"if (result.boolOpt case final $1? ) 'bool': '${$1 }'" },
480480 }, {
481481 & api.Field {Name : "int32_opt" , JSONName : "int32" , Typez : api .INT32_TYPE , Optional : true },
482- []string {"if (result.int32Opt != null ) 'int32': '${result.int32Opt }'" },
482+ []string {"if (result.int32Opt case final $1? ) 'int32': '${$1 }'" },
483483 }, {
484484 & api.Field {Name : "fixed32_opt" , JSONName : "fixed32" , Typez : api .FIXED32_TYPE , Optional : true },
485- []string {"if (result.fixed32Opt != null ) 'fixed32': '${result.fixed32Opt }'" },
485+ []string {"if (result.fixed32Opt case final $1? ) 'fixed32': '${$1 }'" },
486486 }, {
487487 & api.Field {Name : "sfixed32_opt" , JSONName : "sfixed32" , Typez : api .SFIXED32_TYPE , Optional : true },
488- []string {"if (result.sfixed32Opt != null ) 'sfixed32': '${result.sfixed32Opt }'" },
488+ []string {"if (result.sfixed32Opt case final $1? ) 'sfixed32': '${$1 }'" },
489489 }, {
490490 & api.Field {Name : "int64_opt" , JSONName : "int64" , Typez : api .INT64_TYPE , Optional : true },
491- []string {"if (result.int64Opt != null ) 'int64': '${result.int64Opt }'" },
491+ []string {"if (result.int64Opt case final $1? ) 'int64': '${$1 }'" },
492492 }, {
493493 & api.Field {Name : "fixed64_opt" , JSONName : "fixed64" , Typez : api .FIXED64_TYPE , Optional : true },
494- []string {"if (result.fixed64Opt != null ) 'fixed64': '${result.fixed64Opt }'" },
494+ []string {"if (result.fixed64Opt case final $1? ) 'fixed64': '${$1 }'" },
495495 }, {
496496 & api.Field {Name : "sfixed64_opt" , JSONName : "sfixed64" , Typez : api .SFIXED64_TYPE , Optional : true },
497- []string {"if (result.sfixed64Opt != null ) 'sfixed64': '${result.sfixed64Opt }'" },
497+ []string {"if (result.sfixed64Opt case final $1? ) 'sfixed64': '${$1 }'" },
498498 }, {
499499 & api.Field {Name : "double_opt" , JSONName : "double" , Typez : api .DOUBLE_TYPE , Optional : true },
500- []string {"if (result.doubleOpt != null ) 'double': '${result.doubleOpt }'" },
500+ []string {"if (result.doubleOpt case final $1? ) 'double': '${$1 }'" },
501501 }, {
502502 & api.Field {Name : "string_opt" , JSONName : "string" , Typez : api .STRING_TYPE , Optional : true },
503- []string {"if (result.stringOpt != null ) 'string': result.stringOpt! " },
503+ []string {"if (result.stringOpt case final $1? ) 'string': $1 " },
504504 },
505505
506506 // one ofs
507507 {
508508 & api.Field {Name : "bool" , JSONName : "bool" , Typez : api .BOOL_TYPE , IsOneOf : true },
509- []string {"if (result.bool$ != null ) 'bool': '${result.bool$ }'" },
509+ []string {"if (result.bool$ case final $1? ) 'bool': '${$1 }'" },
510510 },
511511
512512 // repeated primitives
513513 {
514514 & api.Field {Name : "boolList" , JSONName : "boolList" , Typez : api .BOOL_TYPE , Repeated : true },
515- []string {"if (result.boolList.isNotDefault) 'boolList': result.boolList! .map((e) => '$e')" },
515+ []string {"if (result.boolList case final $1 when $1 .isNotDefault) 'boolList': $1 .map((e) => '$e')" },
516516 }, {
517517 & api.Field {Name : "int32List" , JSONName : "int32List" , Typez : api .INT32_TYPE , Repeated : true },
518- []string {"if (result.int32List.isNotDefault) 'int32List': result.int32List! .map((e) => '$e')" },
518+ []string {"if (result.int32List case final $1 when $1 .isNotDefault) 'int32List': $1 .map((e) => '$e')" },
519519 }, {
520520 & api.Field {Name : "int64List" , JSONName : "int64List" , Typez : api .INT64_TYPE , Repeated : true },
521- []string {"if (result.int64List.isNotDefault) 'int64List': result.int64List! .map((e) => '$e')" },
521+ []string {"if (result.int64List case final $1 when $1 .isNotDefault) 'int64List': $1 .map((e) => '$e')" },
522522 }, {
523523 & api.Field {Name : "doubleList" , JSONName : "doubleList" , Typez : api .DOUBLE_TYPE , Repeated : true },
524- []string {"if (result.doubleList.isNotDefault) 'doubleList': result.doubleList! .map((e) => '$e')" },
524+ []string {"if (result.doubleList case final $1 when $1 .isNotDefault) 'doubleList': $1 .map((e) => '$e')" },
525525 }, {
526526 & api.Field {Name : "stringList" , JSONName : "stringList" , Typez : api .STRING_TYPE , Repeated : true },
527- []string {"if (result.stringList.isNotDefault) 'stringList': result.stringList " },
527+ []string {"if (result.stringList case final $1 when $1 .isNotDefault) 'stringList': $1 " },
528528 },
529529
530530 // repeated primitives w/ optional
531531 {
532532 & api.Field {Name : "int32List_opt" , JSONName : "int32List" , Typez : api .INT32_TYPE , Repeated : true , Optional : true },
533- []string {"if (result.int32ListOpt.isNotDefault) 'int32List': result.int32ListOpt! .map((e) => '$e')" },
533+ []string {"if (result.int32ListOpt case final $1 when $1 .isNotDefault) 'int32List': $1 .map((e) => '$e')" },
534534 },
535535
536536 // bytes, repeated bytes
537537 {
538538 & api.Field {Name : "bytes" , JSONName : "bytes" , Typez : api .BYTES_TYPE },
539- []string {"if (result.bytes != null ) 'bytes': encodeBytes(result.bytes )!" },
539+ []string {"if (result.bytes case final $1? ) 'bytes': encodeBytes($1 )!" },
540540 }, {
541541 & api.Field {Name : "bytesList" , JSONName : "bytesList" , Typez : api .BYTES_TYPE , Repeated : true },
542- []string {"if (result.bytesList != null ) 'bytesList': result.bytesList! .map((e) => encodeBytes(e)!)" },
542+ []string {"if (result.bytesList case final $1? ) 'bytesList': $1 .map((e) => encodeBytes(e)!)" },
543543 },
544544 } {
545545 t .Run (test .field .Name , func (t * testing.T ) {
@@ -596,7 +596,7 @@ func TestBuildQueryLinesEnums(t *testing.T) {
596596 JSONName : "jsonEnumName" ,
597597 Typez : api .ENUM_TYPE ,
598598 TypezID : enum .ID },
599- []string {"if (result.enumName.isNotDefault) 'jsonEnumName': result.enumName .value" },
599+ []string {"if (result.enumName case final $1 when $1 .isNotDefault) 'jsonEnumName': $1 .value" },
600600 },
601601 {
602602 & api.Field {
@@ -605,7 +605,7 @@ func TestBuildQueryLinesEnums(t *testing.T) {
605605 Typez : api .ENUM_TYPE ,
606606 TypezID : enum .ID ,
607607 Optional : true },
608- []string {"if (result.optionalEnum != null ) 'optionalJsonEnum': result.optionalEnum! .value" },
608+ []string {"if (result.optionalEnum case final $1? ) 'optionalJsonEnum': $1 .value" },
609609 },
610610 {
611611 & api.Field {
@@ -614,7 +614,7 @@ func TestBuildQueryLinesEnums(t *testing.T) {
614614 Typez : api .ENUM_TYPE ,
615615 TypezID : foreignEnumState .ID ,
616616 Optional : false },
617- []string {"if (result.enumName.isNotDefault) 'jsonEnumName': result.enumName .value" },
617+ []string {"if (result.enumName case final $1 when $1 .isNotDefault) 'jsonEnumName': $1 .value" },
618618 },
619619 } {
620620 t .Run (test .enumField .Name , func (t * testing.T ) {
@@ -683,17 +683,17 @@ func TestBuildQueryLinesMessages(t *testing.T) {
683683 // messages
684684 got := annotate .buildQueryLines ([]string {}, "result." , "" , messageField1 , model .State )
685685 want := []string {
686- "if (result.message1!.name.isNotDefault) 'message1.name': result.message1!.name " ,
687- "if (result.message1!.state.isNotDefault) 'message1.state': result.message1!.state .value" ,
686+ "if (result.message1!.name case final $1 when $1 .isNotDefault) 'message1.name': $1 " ,
687+ "if (result.message1!.state case final $1 when $1 .isNotDefault) 'message1.state': $1 .value" ,
688688 }
689689 if diff := cmp .Diff (want , got ); diff != "" {
690690 t .Errorf ("mismatch in TestBuildQueryLines (-want, +got)\n :%s" , diff )
691691 }
692692
693693 got = annotate .buildQueryLines ([]string {}, "result." , "" , messageField2 , model .State )
694694 want = []string {
695- "if (result.message2!.data != null ) 'message2.data': encodeBytes(result.message2!.data )!" ,
696- "if (result.message2!.dataCrc32C != null ) 'message2.dataCrc32c': '${result.message2!.dataCrc32C }'" ,
695+ "if (result.message2!.data case final $1? ) 'message2.data': encodeBytes($1 )!" ,
696+ "if (result.message2!.dataCrc32C case final $1? ) 'message2.dataCrc32c': '${$1 }'" ,
697697 }
698698 if diff := cmp .Diff (want , got ); diff != "" {
699699 t .Errorf ("mismatch in TestBuildQueryLines (-want, +got)\n :%s" , diff )
@@ -702,8 +702,8 @@ func TestBuildQueryLinesMessages(t *testing.T) {
702702 // nested messages
703703 got = annotate .buildQueryLines ([]string {}, "result." , "" , messageField3 , model .State )
704704 want = []string {
705- "if (result.message3!.secret!.name.isNotDefault) 'message3.secret.name': result.message3!.secret!.name " ,
706- "if (result.message3!.fieldMask != null ) 'message3.fieldMask': result.message3!.fieldMask! .toJson()" ,
705+ "if (result.message3!.secret!.name case final $1 when $1 .isNotDefault) 'message3.secret.name': $1 " ,
706+ "if (result.message3!.fieldMask case final $1? ) 'message3.fieldMask': $1 .toJson()" ,
707707 }
708708 if diff := cmp .Diff (want , got ); diff != "" {
709709 t .Errorf ("mismatch in TestBuildQueryLines (-want, +got)\n :%s" , diff )
@@ -712,23 +712,23 @@ func TestBuildQueryLinesMessages(t *testing.T) {
712712 // custom encoded messages
713713 got = annotate .buildQueryLines ([]string {}, "result." , "" , fieldMaskField , model .State )
714714 want = []string {
715- "if (result.fieldMask != null ) 'fieldMask': result.fieldMask! .toJson()" ,
715+ "if (result.fieldMask case final $1? ) 'fieldMask': $1 .toJson()" ,
716716 }
717717 if diff := cmp .Diff (want , got ); diff != "" {
718718 t .Errorf ("mismatch in TestBuildQueryLines (-want, +got)\n :%s" , diff )
719719 }
720720
721721 got = annotate .buildQueryLines ([]string {}, "result." , "" , durationField , model .State )
722722 want = []string {
723- "if (result.duration != null ) 'duration': result.duration! .toJson()" ,
723+ "if (result.duration case final $1? ) 'duration': $1 .toJson()" ,
724724 }
725725 if diff := cmp .Diff (want , got ); diff != "" {
726726 t .Errorf ("mismatch in TestBuildQueryLines (-want, +got)\n :%s" , diff )
727727 }
728728
729729 got = annotate .buildQueryLines ([]string {}, "result." , "" , timestampField , model .State )
730730 want = []string {
731- "if (result.time != null ) 'time': result.time! .toJson()" ,
731+ "if (result.time case final $1? ) 'time': $1 .toJson()" ,
732732 }
733733 if diff := cmp .Diff (want , got ); diff != "" {
734734 t .Errorf ("mismatch in TestBuildQueryLines (-want, +got)\n :%s" , diff )
0 commit comments