aboutsummaryrefslogtreecommitdiffstats
path: root/src/google/protobuf/compiler/javanano/javanano_message_field.cc
diff options
context:
space:
mode:
authorAndrew Flynn <flynn@google.com>2013-12-04 13:10:07 -0800
committerAndrew Flynn <flynn@google.com>2013-12-09 11:40:03 -0800
commit102cfe65b9b9e2b458c3d0ec69d47e8fc40dc726 (patch)
tree196b5f09c23bb1dddc242ef002106b78afdaff1a /src/google/protobuf/compiler/javanano/javanano_message_field.cc
parentc4c4a562672068fb89ea4e65408dd53de2ed8f1f (diff)
downloadexternal_protobuf-102cfe65b9b9e2b458c3d0ec69d47e8fc40dc726.zip
external_protobuf-102cfe65b9b9e2b458c3d0ec69d47e8fc40dc726.tar.gz
external_protobuf-102cfe65b9b9e2b458c3d0ec69d47e8fc40dc726.tar.bz2
Nano: don't generate accessor methods for nested methods
For nested message objects, don't generate accessor methods because they have a default value that is not a valid value (null), so there is no reason to have get/set/has/clear methods for them. Clients and protos (while serializing) can check against the invalid value to see if it's been set. Change-Id: Ic63400889581271b8cbcd9c45c84519d4921fd4b
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_message_field.cc')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_message_field.cc91
1 files changed, 0 insertions, 91 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_message_field.cc b/src/google/protobuf/compiler/javanano/javanano_message_field.cc
index d9abea3..74d3f85 100644
--- a/src/google/protobuf/compiler/javanano/javanano_message_field.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_message_field.cc
@@ -149,97 +149,6 @@ GenerateHashCodeCode(io::Printer* printer) const {
// ===================================================================
-AccessorMessageFieldGenerator::
-AccessorMessageFieldGenerator(
- const FieldDescriptor* descriptor, const Params& params)
- : FieldGenerator(params), descriptor_(descriptor) {
- SetMessageVariables(params, descriptor, &variables_);
-}
-
-AccessorMessageFieldGenerator::~AccessorMessageFieldGenerator() {}
-
-void AccessorMessageFieldGenerator::
-GenerateMembers(io::Printer* printer) const {
- printer->Print(variables_,
- "private $type$ $name$_;\n"
- "public $type$ get$capitalized_name$() {\n"
- " return $name$_;\n"
- "}\n"
- "public $message_name$ set$capitalized_name$($type$ value) {\n"
- " if (value == null) {\n"
- " throw new java.lang.NullPointerException();\n"
- " }\n"
- " $name$_ = value;\n"
- " return this;\n"
- "}\n"
- "public boolean has$capitalized_name$() {\n"
- " return $name$_ != null;\n"
- "}\n"
- "public $message_name$ clear$capitalized_name$() {\n"
- " $name$_ = null;\n"
- " return this;"
- "}\n");
-}
-
-void AccessorMessageFieldGenerator::
-GenerateClearCode(io::Printer* printer) const {
- printer->Print(variables_,
- "$name$_ = null;\n");
-}
-
-void AccessorMessageFieldGenerator::
-GenerateMergingCode(io::Printer* printer) const {
- printer->Print(variables_,
- "if ($name$_ == null) {\n"
- " $name$_ = new $type$();\n"
- "}\n");
-
- if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) {
- printer->Print(variables_,
- "input.readGroup($name$_, $number$);\n");
- } else {
- printer->Print(variables_,
- "input.readMessage($name$_);\n");
- }
-}
-
-void AccessorMessageFieldGenerator::
-GenerateSerializationCode(io::Printer* printer) const {
- printer->Print(variables_,
- "if ($name$_ != null) {\n"
- " output.write$group_or_message$($number$, $name$_);\n"
- "}\n");
-}
-
-void AccessorMessageFieldGenerator::
-GenerateSerializedSizeCode(io::Printer* printer) const {
- printer->Print(variables_,
- "if ($name$_ != null) {\n"
- " size += com.google.protobuf.nano.CodedOutputByteBufferNano\n"
- " .compute$group_or_message$Size($number$, $name$_);\n"
- "}\n");
-}
-
-void AccessorMessageFieldGenerator::
-GenerateEqualsCode(io::Printer* printer) const {
- printer->Print(variables_,
- "if ($name$_ == null) {\n"
- " if (other.$name$_ != null) {\n"
- " return false;\n"
- " }\n"
- "} else if (!$name$_.equals(other.$name$_)) {\n"
- " return false;\n"
- "}\n");
-}
-
-void AccessorMessageFieldGenerator::
-GenerateHashCodeCode(io::Printer* printer) const {
- printer->Print(variables_,
- "result = 31 * result + ($name$_ == null ? 0 : $name$_.hashCode());\n");
-}
-
-// ===================================================================
-
RepeatedMessageFieldGenerator::
RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, const Params& params)
: FieldGenerator(params), descriptor_(descriptor) {