THRIFT-316. java: @Override isn't generated for hashCode() without the hash code builder
Fixed with a trivial reorganization of the hashCode method generation.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@743046 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index a9ad54f..e8eab5c 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -861,13 +861,11 @@
scope_down(out);
out << endl;
+ out << indent() << "@Override" << endl <<
+ indent() << "public int hashCode() {" << endl;
+ indent_up();
if (gen_hash_code_) {
- out << indent() << "@Override" << endl <<
- indent() << "public int hashCode() {" << endl;
- indent_up();
-
- out <<
- indent() << "HashCodeBuilder builder = new HashCodeBuilder();" << endl;
+ indent(out) << "HashCodeBuilder builder = new HashCodeBuilder();" << endl;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
out << endl;
@@ -895,20 +893,12 @@
}
out << endl;
- out <<
- indent() << "return builder.toHashCode();" << endl;
- scope_down(out);
- out << endl;
-
+ indent(out) << "return builder.toHashCode();" << endl;
} else {
- out <<
- indent() << "public int hashCode() {" << endl;
- indent_up();
- out <<
- indent() << "return 0;" << endl;
- scope_down(out);
- out << endl;
+ indent(out) << "return 0;" << endl;
}
+ indent_down();
+ indent(out) << "}" << endl << endl;
}
/**