*/
#include <cassert>
+#include <ctime>
#include <sstream>
#include <string>
void generate_java_struct_tuple_reader(ofstream& out, t_struct* tstruct);
void generate_java_struct_tuple_writer(ofstream& out, t_struct* tstruct);
+ void generate_javax_generated_annotation(ofstream& out);
/**
* Serialization constructs
*/
"import java.util.BitSet;\n" +
"import java.nio.ByteBuffer;\n"
"import java.util.Arrays;\n" +
+ "import javax.annotation.Generated;\n" +
"import org.slf4j.Logger;\n" +
"import org.slf4j.LoggerFactory;\n\n";
}
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
+ if (!in_class) {
+ generate_javax_generated_annotation(out);
+ }
+
indent(out) <<
"public " << (is_final ? "final " : "") <<
(in_class ? "static " : "") << "class " << tstruct->get_name() << " ";
java_package() <<
java_type_imports();
+ generate_javax_generated_annotation(f_service_);
f_service_ << "public class " << service_name_ << " {" << endl << endl;
indent_up();
out << indent() << "}" << endl << endl;
}
+void t_java_generator::generate_javax_generated_annotation(ofstream& out){
+ time_t seconds = time(NULL);
+ struct tm *now = localtime(&seconds);
+ indent(out) << "@Generated(value = \"" << autogen_summary()
+ << "\", date = \"" << (now->tm_year + 1900)
+ << "-" << (now->tm_mon + 1) << "-" << now->tm_mday
+ << "\")" << endl;
+}
+
THRIFT_REGISTER_GENERATOR(java, "Java",
" beans: Members will be private, and setter methods will return void.\n"
" private-members: Members will be private, but setter methods will return 'this' like usual.\n"
virtual std::string autogen_comment() {
return
std::string("/**\n") +
- " * Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
+ " * " + autogen_summary() + "\n" +
" *\n" +
" * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
" * @generated\n" +
" */\n";
}
+
+ virtual std::string autogen_summary() {
+ return
+ std::string("Autogenerated by Thrift Compiler (") + THRIFT_VERSION + ")";
+ }
};
#endif