aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/java/java_enum.cc
diff options
context:
space:
mode:
authorkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-01-28 01:09:11 +0000
committerkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-01-28 01:09:11 +0000
commitab6950d75d6bae6a1574726ee1e7060e001ed23a (patch)
treee2c38cfedf5f102997688c76c47ed4986518ebb1 /src/google/protobuf/compiler/java/java_enum.cc
parent28c2ec0dbdd6f1b0ea844f1ccce6c8f05ae917e8 (diff)
downloadprotobuf-ab6950d75d6bae6a1574726ee1e7060e001ed23a.tar.gz
protobuf-ab6950d75d6bae6a1574726ee1e7060e001ed23a.tar.bz2
protobuf-ab6950d75d6bae6a1574726ee1e7060e001ed23a.zip
More Java warning tweaks from Evan Jones.
Diffstat (limited to 'src/google/protobuf/compiler/java/java_enum.cc')
-rw-r--r--src/google/protobuf/compiler/java/java_enum.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc
index 85e39f53..e796587f 100644
--- a/src/google/protobuf/compiler/java/java_enum.cc
+++ b/src/google/protobuf/compiler/java/java_enum.cc
@@ -138,7 +138,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
" internalValueMap =\n"
" new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\n"
" public $classname$ findValueByNumber(int number) {\n"
- " return $classname$.valueOf(number)\n;"
+ " return $classname$.valueOf(number);\n"
" }\n"
" };\n"
"\n",
@@ -190,6 +190,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
printer->Print(
"\n"
"};\n"
+ "\n"
"public static $classname$ valueOf(\n"
" com.google.protobuf.Descriptors.EnumValueDescriptor desc) {\n"
" if (desc.getType() != getDescriptor()) {\n"
@@ -197,20 +198,26 @@ void EnumGenerator::Generate(io::Printer* printer) {
" \"EnumValueDescriptor is not for this type.\");\n"
" }\n"
" return VALUES[desc.getIndex()];\n"
- "}\n",
+ "}\n"
+ "\n",
"classname", descriptor_->name());
+
+ // index is only used for reflection; lite implementation does not need it
+ printer->Print("private final int index;\n");
}
// -----------------------------------------------------------------
printer->Print(
- "private final int index;\n"
- "private final int value;\n"
- "private $classname$(int index, int value) {\n"
- " this.index = index;\n"
- " this.value = value;\n"
- "}\n",
+ "private final int value;\n\n"
+ "private $classname$(int index, int value) {\n",
"classname", descriptor_->name());
+ if (HasDescriptorMethods(descriptor_)) {
+ printer->Print(" this.index = index;\n");
+ }
+ printer->Print(
+ " this.value = value;\n"
+ "}\n");
if (HasDescriptorMethods(descriptor_)) {
// Force the static initialization code for the file to run, since it may