Fix review comments.
Change-Id: Iafd4a3aa9d55e31478bf070311eeadfe95ece4d7
This commit is contained in:
parent
f2cf6cdcb2
commit
a6fc5da0fc
@ -3741,7 +3741,7 @@ public class NanoTest extends TestCase {
|
|||||||
checkOneofCase(m, 0);
|
checkOneofCase(m, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOneofMarshling() throws Exception {
|
public void testOneofMarshaling() throws Exception {
|
||||||
TestAllTypesNano m = new TestAllTypesNano();
|
TestAllTypesNano m = new TestAllTypesNano();
|
||||||
TestAllTypesNano parsed = new TestAllTypesNano();
|
TestAllTypesNano parsed = new TestAllTypesNano();
|
||||||
{
|
{
|
||||||
|
@ -174,15 +174,10 @@ void GenerateOneofFieldEquals(const FieldDescriptor* descriptor,
|
|||||||
if (GetJavaType(descriptor) == JAVATYPE_BYTES) {
|
if (GetJavaType(descriptor) == JAVATYPE_BYTES) {
|
||||||
printer->Print(variables,
|
printer->Print(variables,
|
||||||
"if (this.has$capitalized_name$()) {\n"
|
"if (this.has$capitalized_name$()) {\n"
|
||||||
" if (!other.has$capitalized_name$() ||\n"
|
" if (!java.util.Arrays.equals((byte[]) this.$oneof_name$_,\n"
|
||||||
" !java.util.Arrays.equals((byte[]) this.$oneof_name$_,\n"
|
|
||||||
" (byte[]) other.$oneof_name$_)) {\n"
|
" (byte[]) other.$oneof_name$_)) {\n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"} else {\n"
|
|
||||||
" if (other.has$capitalized_name$()) {\n"
|
|
||||||
" return false;\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n");
|
"}\n");
|
||||||
} else {
|
} else {
|
||||||
printer->Print(variables,
|
printer->Print(variables,
|
||||||
@ -190,10 +185,6 @@ void GenerateOneofFieldEquals(const FieldDescriptor* descriptor,
|
|||||||
" if (!this.$oneof_name$_.equals(other.$oneof_name$_)) {\n"
|
" if (!this.$oneof_name$_.equals(other.$oneof_name$_)) {\n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"} else {\n"
|
|
||||||
" if (other.has$capitalized_name$()) {\n"
|
|
||||||
" return false;\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n");
|
"}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,6 +551,16 @@ void MessageGenerator::GenerateEquals(io::Printer* printer) {
|
|||||||
"$classname$ other = ($classname$) o;\n",
|
"$classname$ other = ($classname$) o;\n",
|
||||||
"classname", descriptor_->name());
|
"classname", descriptor_->name());
|
||||||
|
|
||||||
|
// Checking oneof case before checking each oneof field.
|
||||||
|
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
|
||||||
|
const OneofDescriptor* oneof_desc = descriptor_->oneof_decl(i);
|
||||||
|
printer->Print(
|
||||||
|
"if (this.$oneof_name$Case_ != other.$oneof_name$Case_) {\n"
|
||||||
|
" return false;\n"
|
||||||
|
"}\n",
|
||||||
|
"oneof_name", UnderscoresToCamelCase(oneof_desc));
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < descriptor_->field_count(); i++) {
|
for (int i = 0; i < descriptor_->field_count(); i++) {
|
||||||
const FieldDescriptor* field = descriptor_->field(i);
|
const FieldDescriptor* field = descriptor_->field(i);
|
||||||
field_generators_.get(field).GenerateEqualsCode(printer);
|
field_generators_.get(field).GenerateEqualsCode(printer);
|
||||||
|
Loading…
Reference in New Issue
Block a user