mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
THRIFT-1752 structs do not implement Comparable and have a redundant cast
Patch: Andrew Gaul git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1410061 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3806a743c8
commit
32104d71bd
@ -1245,7 +1245,7 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
|
||||
if (is_exception) {
|
||||
out << "extends TException ";
|
||||
}
|
||||
out << "implements org.apache.thrift.TBase<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields>, java.io.Serializable, Cloneable";
|
||||
out << "implements org.apache.thrift.TBase<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields>, java.io.Serializable, Cloneable, Comparable<" << tstruct->get_name() << ">";
|
||||
|
||||
out << " ";
|
||||
|
||||
@ -1577,6 +1577,7 @@ void t_java_generator::generate_java_struct_equality(ofstream& out,
|
||||
}
|
||||
|
||||
void t_java_generator::generate_java_struct_compare_to(ofstream& out, t_struct* tstruct) {
|
||||
indent(out) << "@Override" << endl;
|
||||
indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
|
||||
indent_up();
|
||||
|
||||
@ -1586,20 +1587,19 @@ void t_java_generator::generate_java_struct_compare_to(ofstream& out, t_struct*
|
||||
out << endl;
|
||||
|
||||
indent(out) << "int lastComparison = 0;" << endl;
|
||||
indent(out) << type_name(tstruct) << " typedOther = (" << type_name(tstruct) << ")other;" << endl;
|
||||
out << endl;
|
||||
|
||||
const vector<t_field*>& members = tstruct->get_members();
|
||||
vector<t_field*>::const_iterator m_iter;
|
||||
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
||||
t_field* field = *m_iter;
|
||||
indent(out) << "lastComparison = Boolean.valueOf(" << generate_isset_check(field) << ").compareTo(typedOther." << generate_isset_check(field) << ");" << endl;
|
||||
indent(out) << "lastComparison = Boolean.valueOf(" << generate_isset_check(field) << ").compareTo(other." << generate_isset_check(field) << ");" << endl;
|
||||
indent(out) << "if (lastComparison != 0) {" << endl;
|
||||
indent(out) << " return lastComparison;" << endl;
|
||||
indent(out) << "}" << endl;
|
||||
|
||||
indent(out) << "if (" << generate_isset_check(field) << ") {" << endl;
|
||||
indent(out) << " lastComparison = org.apache.thrift.TBaseHelper.compareTo(this." << field->get_name() << ", typedOther." << field->get_name() << ");" << endl;
|
||||
indent(out) << " lastComparison = org.apache.thrift.TBaseHelper.compareTo(this." << field->get_name() << ", other." << field->get_name() << ");" << endl;
|
||||
indent(out) << " if (lastComparison != 0) {" << endl;
|
||||
indent(out) << " return lastComparison;" << endl;
|
||||
indent(out) << " }" << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user