summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorJeff Davidson <jpd@google.com>2015-02-11 13:12:14 -0800
committerJeff Davidson <jpd@google.com>2015-02-19 19:55:26 +0000
commit30d873bd66f50a6021de5d44d7ee5b8a809b0524 (patch)
treec4cec97120f5b387aa9ea6910ff1e839725ccfb8 /java
parenteb5ae9e258a8fc953e6cf0b3a0dd04a112a05a3c (diff)
downloadexternal_protobuf-30d873bd66f50a6021de5d44d7ee5b8a809b0524.zip
external_protobuf-30d873bd66f50a6021de5d44d7ee5b8a809b0524.tar.gz
external_protobuf-30d873bd66f50a6021de5d44d7ee5b8a809b0524.tar.bz2
Generate @IntDef annotations for nanoproto enums.
@IntDef is a support library annotation which allows build tools to determine the valid set of values for a given integer field when that field is intended to be restricted like an enum. This avoids the overhead of enums while still allowing for compile-time type checking in most circumstances. Change-Id: Iee02e0b49a8e069f6456572f538e0a0d301fdfd5
Diffstat (limited to 'java')
-rw-r--r--java/README.txt24
1 files changed, 23 insertions, 1 deletions
diff --git a/java/README.txt b/java/README.txt
index 7081a84..b02e88b 100644
--- a/java/README.txt
+++ b/java/README.txt
@@ -593,6 +593,28 @@ ignore_services={true,false} (default: false)
parcelable_messages={true,false} (default: false)
Android-specific option to generate Parcelable messages.
+generate_intdefs={true,false} (default: false)
+ Android-specific option to generate @IntDef annotations for enums.
+
+ If turned on, an @IntDef annotation (a public @interface) will be
+ generated for each enum, and every integer parameter and return
+ value in the generated code meant for this enum will be annotated
+ with it. This interface is generated with the same name and at the
+ same place as the enum members' container interfaces described
+ above under enum_style=java, regardless of the enum_style option
+ used. When this is combined with enum_style=java, the interface
+ will be both the @IntDef annotation and the container of the enum
+ members; otherwise the interface has an empty body.
+
+ Your app must declare a compile-time dependency on the
+ android-support-annotations library.
+
+ For more information on how these @IntDef annotations help with
+ compile-time type safety, see:
+ https://sites.google.com/a/android.com/tools/tech-docs/support-annotations
+ and
+ https://developer.android.com/reference/android/support/annotation/IntDef.html
+
To use nano protobufs within the Android repo:
@@ -646,7 +668,7 @@ Please run the following steps to test:
- "make -j12 aprotoc libprotobuf-java-nano aprotoc-test-nano-params NanoAndroidTest" and
check for build errors.
- Plug in an Android device or start an emulator.
-- adb install -r out/target/product/generic/data/app/NanoAndroidTest.apk
+- adb install -r out/target/product/generic/data/app/NanoAndroidTest/NanoAndroidTest.apk
- Run:
"adb shell am instrument -w com.google.protobuf.nano.test/android.test.InstrumentationTestRunner"
and verify all tests pass.