@ -86,9 +86,6 @@ void SetMessageVariables(
( * variables ) [ " set_has_field_bit_to_local " ] =
GenerateSetBitToLocal ( messageBitIndex ) ;
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
( * variables ) [ " null_check " ] = " value.getClass(); \n " ;
// Annotations often use { and } to determine ranges.
( * variables ) [ " { " ] = " " ;
( * variables ) [ " } " ] = " " ;
@ -178,8 +175,9 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers(
// Field.Builder setField(Field value)
WriteFieldDocComment ( printer , descriptor_ , context_ - > options ( ) ) ;
printer - > Print ( variables_ ,
" @java.lang.SuppressWarnings( \" ReturnValueIgnored \" ) \n "
" private void set$capitalized_name$($type$ value) { \n "
" $null_check$ "
" value.getClass(); // minimal bytecode null check \n "
" $name$_ = value; \n "
" $set_has_field_bit_message$ \n "
" } \n " ) ;
@ -188,9 +186,10 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers(
WriteFieldDocComment ( printer , descriptor_ , context_ - > options ( ) ) ;
printer - > Print (
variables_ ,
" @java.lang.SuppressWarnings({ \" ReferenceEquality \" }) \n "
" @java.lang.SuppressWarnings({ \" ReferenceEquality \" , "
" \" ReturnValueIgnored \" }) \n "
" private void merge$capitalized_name$($type$ value) { \n "
" $null_check$ "
" value.getClass(); // minimal bytecode null check \n "
" if ($name$_ != null && \n "
" $name$_ != $type$.getDefaultInstance()) { \n "
" $name$_ = \n "
@ -384,8 +383,9 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers(
// Field.Builder setField(Field value)
WriteFieldDocComment ( printer , descriptor_ , context_ - > options ( ) ) ;
printer - > Print ( variables_ ,
" @java.lang.SuppressWarnings( \" ReturnValueIgnored \" ) \n "
" private void set$capitalized_name$($type$ value) { \n "
" $null_check$ "
" value.getClass(); // minimal bytecode null check \n "
" $oneof_name$_ = value; \n "
" $set_oneof_case_message$; \n "
" } \n " ) ;
@ -394,8 +394,9 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers(
WriteFieldDocComment ( printer , descriptor_ , context_ - > options ( ) ) ;
printer - > Print (
variables_ ,
" @java.lang.SuppressWarnings( \" ReturnValueIgnored \" ) \n "
" private void merge$capitalized_name$($type$ value) { \n "
" $null_check$ "
" value.getClass(); // minimal bytecode null check \n "
" if ($has_oneof_case_message$ && \n "
" $oneof_name$_ != $type$.getDefaultInstance()) { \n "
" $oneof_name$_ = $type$.newBuilder(($type$) $oneof_name$_) \n "
@ -599,9 +600,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
// Builder setRepeatedField(int index, Field value)
WriteFieldDocComment ( printer , descriptor_ , context_ - > options ( ) ) ;
printer - > Print ( variables_ ,
" @java.lang.SuppressWarnings( \" ReturnValueIgnored \" ) \n "
" private void set$capitalized_name$( \n "
" int index, $type$ value) { \n "
" $null_check$ "
" value.getClass(); // minimal bytecode null check \n "
" ensure$capitalized_name$IsMutable(); \n "
" $name$_.set(index, value); \n "
" } \n " ) ;
@ -609,8 +611,9 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
// Builder addRepeatedField(Field value)
WriteFieldDocComment ( printer , descriptor_ , context_ - > options ( ) ) ;
printer - > Print ( variables_ ,
" @java.lang.SuppressWarnings( \" ReturnValueIgnored \" ) \n "
" private void add$capitalized_name$($type$ value) { \n "
" $null_check$ "
" value.getClass(); // minimal bytecode null check \n "
" ensure$capitalized_name$IsMutable(); \n "
" $name$_.add(value); \n "
" } \n " ) ;
@ -618,9 +621,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
// Builder addRepeatedField(int index, Field value)
WriteFieldDocComment ( printer , descriptor_ , context_ - > options ( ) ) ;
printer - > Print ( variables_ ,
" @java.lang.SuppressWarnings( \" ReturnValueIgnored \" ) \n "
" private void add$capitalized_name$( \n "
" int index, $type$ value) { \n "
" $null_check$ "
" value.getClass(); // minimal bytecode null check \n "
" ensure$capitalized_name$IsMutable(); \n "
" $name$_.add(index, value); \n "
" } \n " ) ;