diff options
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_enum.cc')
-rw-r--r-- | src/google/protobuf/compiler/javanano/javanano_enum.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_enum.cc b/src/google/protobuf/compiler/javanano/javanano_enum.cc index 5abd46e..6ba25eb 100644 --- a/src/google/protobuf/compiler/javanano/javanano_enum.cc +++ b/src/google/protobuf/compiler/javanano/javanano_enum.cc @@ -69,6 +69,17 @@ EnumGenerator::~EnumGenerator() {} void EnumGenerator::Generate(io::Printer* printer) { printer->Print("// enum $classname$\n", "classname", descriptor_->name()); + bool is_own_file = params_.java_multiple_files() || + ((descriptor_->containing_type() == NULL) && + !params_.has_java_outer_classname(descriptor_->file()->name())); + + if (is_own_file) { + printer->Print("public final class $classname$ {\n", "classname", + descriptor_->name()); + printer->Indent(); + printer->Print("private $classname$() {}\n", "classname", + descriptor_->name()); + } for (int i = 0; i < canonical_values_.size(); i++) { map<string, string> vars; vars["name"] = canonical_values_[i]->name(); @@ -87,6 +98,10 @@ void EnumGenerator::Generate(io::Printer* printer) { "public static final int $name$ = $canonical_name$;\n"); } + if (is_own_file) { + printer->Outdent(); + printer->Print("}"); + } printer->Print("\n"); } |