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 << " ";
}
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();
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;