summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Flynn <flynn@google.com>2013-10-08 11:14:51 -0700
committerAndrew Flynn <flynn@google.com>2013-10-08 12:47:35 -0700
commit5dca493053aa93bdd2b5dba842ad87d34ba31521 (patch)
treedc507071467ab8aa35d9ccae3ac9b62aafc5fa7d /src
parent9827c718c45cfa1744a3b0f8fc27dac9cd415603 (diff)
downloadexternal_protobuf-5dca493053aa93bdd2b5dba842ad87d34ba31521.zip
external_protobuf-5dca493053aa93bdd2b5dba842ad87d34ba31521.tar.gz
external_protobuf-5dca493053aa93bdd2b5dba842ad87d34ba31521.tar.bz2
Fix some indenting issues with set__() function
Previously it looked like this: public final class OuterClass { [...] public static final class InnerClass extends com.google.protobuf.nano.MessageNano { [...] public void setId(java.lang.String value) { if (value == null) { throw new java.lang.NullPointerException(); } id_ = value; bitfield0_ |= 0x00000001; [...] } [...] } Now it looks like this: public final class OuterClass { [...] public static final class InnerClass extends com.google.protobuf.nano.MessageNano { [...] public void setId(java.lang.String value) { if (value == null) throw new java.lang.NullPointerException(); id_ = value; bitfield0_ |= 0x00000001; [...] } [...] } Change-Id: I2a9289b528f785c846210d558206d677aa13e9be
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_primitive_field.cc16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc b/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
index 69664d3..fe6a48f 100644
--- a/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
@@ -281,14 +281,6 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, const Params param
(*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), descriptor->type()));
- if (IsReferenceType(GetJavaType(descriptor))) {
- (*variables)["null_check"] =
- " if (value == null) {\n"
- " throw new java.lang.NullPointerException();\n"
- " }\n";
- } else {
- (*variables)["null_check"] = "";
- }
int fixed_size = FixedSize(descriptor->type());
if (fixed_size != -1) {
(*variables)["fixed_size"] = SimpleItoa(fixed_size);
@@ -425,8 +417,12 @@ GenerateMembers(io::Printer* printer) const {
"public $type$ get$capitalized_name$() {\n"
" return $name$_;\n"
"}\n"
- "public void set$capitalized_name$($type$ value) {\n"
- "$null_check$"
+ "public void set$capitalized_name$($type$ value) {\n");
+ if (IsReferenceType(GetJavaType(descriptor_))) {
+ printer->Print(variables_,
+ " if (value == null) throw new java.lang.NullPointerException();\n");
+ }
+ printer->Print(variables_,
" $name$_ = value;\n"
" $set_has$;\n"
"}\n"