aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/javanano/javanano_field.cc
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2015-02-18 13:47:22 -0800
committerGravatar Jisi Liu <jisi.liu@gmail.com>2015-02-19 16:43:08 -0800
commitf173cdeb02618c117947bbed2646609f6101390e (patch)
tree1291766ddd482f9cda803df7c3e7e8bc1887d8bb /src/google/protobuf/compiler/javanano/javanano_field.cc
parent06a2e29855efbd67c86171ee822ec2e217f6fe29 (diff)
hashcode and equals for oneofs in nano.
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_field.cc')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_field.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_field.cc b/src/google/protobuf/compiler/javanano/javanano_field.cc
index 5565781c..07517567 100644
--- a/src/google/protobuf/compiler/javanano/javanano_field.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_field.cc
@@ -168,6 +168,28 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor,
SimpleItoa(descriptor->number());
}
+void GenerateOneofFieldEquals(const map<string, string>& variables,
+ io::Printer* printer) {
+ printer->Print(variables,
+ "if (this.has$capitalized_name$()) {\n"
+ " if (!this.$oneof_name$_.equals(other.$oneof_name$_)) {\n"
+ " return false;\n"
+ " }\n"
+ "} else {\n"
+ " if (other.has$capitalized_name$()) {\n"
+ " return false;\n"
+ " }\n"
+ "}\n");
+
+}
+
+void GenerateOneofFieldHashCode(const map<string, string>& variables,
+ io::Printer* printer) {
+ printer->Print(variables,
+ "result = 31 * result +\n"
+ " ($has_oneof_case$ ? this.$oneof_name$_.hashCode() : 0);\n");
+}
+
} // namespace javanano
} // namespace compiler
} // namespace protobuf