From 339c783b4af158558e1e054594f1180f07950485 Mon Sep 17 00:00:00 2001 From: Emmanuel Cron Date: Tue, 6 Oct 2015 16:20:37 -0700 Subject: [PATCH] Updated the ProtoTypeAdapter to a version that works smoothly and supports field name/value customization. - Lets you customize the proto field name serialization per field - Lets you use different cases for serialization (e.g. you could use UpperCamelCase for your proto field names and willing to serialize them using LowerHyphen) - Lets you choose to serialize enum values with their value (0, 1, 2, ...) instead of their name. --- proto/pom.xml | 39 +- .../gson/protobuf/ProtoTypeAdapter.java | 355 +++++++++++++++--- proto/src/main/protobuf/annotations.proto | 32 ++ proto/src/main/protobuf/bag.proto | 38 +- .../functional/ProtosWithAnnotationsTest.java | 223 +++++++++++ ...rotosWithComplexAndRepeatedFieldsTest.java | 10 +- .../ProtosWithPrimitiveTypesTest.java | 6 +- 7 files changed, 647 insertions(+), 56 deletions(-) create mode 100644 proto/src/main/protobuf/annotations.proto create mode 100644 proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsTest.java diff --git a/proto/pom.xml b/proto/pom.xml index c004fea8..d42be0f9 100644 --- a/proto/pom.xml +++ b/proto/pom.xml @@ -10,6 +10,9 @@ 0.5 Gson Protobuf Support Gson support for Protobufs + + UTF-8 + local.repo @@ -52,21 +55,35 @@ com.google.code.gson gson - 1.7.1 + 2.3.1 compile com.google.protobuf protobuf-java - 2.4.0a + 2.6.1 + compile + + + + com.google.guava + guava + 18.0 compile junit junit - 3.8.2 + 4.12 + test + + + + com.google.truth + truth + 0.27 test @@ -76,7 +93,19 @@ maven-antrun-plugin + 1.8 + + blah + + run + + + + + + + compile-protoc generate-sources @@ -91,6 +120,7 @@ + @@ -125,6 +155,7 @@ org.apache.maven.plugins maven-install-plugin + 2.5.2