Created
January 6, 2014 17:47
-
-
Save creativepsyco/8286534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- i/wire-compiler/src/main/java/com/squareup/wire/MessageWriter.java | |
+++ w/wire-compiler/src/main/java/com/squareup/wire/MessageWriter.java | |
@@ -94,10 +94,20 @@ public class MessageWriter { | |
} else if (type instanceof EnumType) { | |
EnumType enumType = (EnumType) type; | |
writer.beginType(enumType.getName(), "enum", EnumSet.of(PUBLIC)); | |
+ int index = 0; | |
for (EnumType.Value value : enumType.getValues()) { | |
MessageWriter.emitDocumentation(writer, value.getDocumentation()); | |
writer.emitAnnotation(ProtoEnum.class, value.getTag()); | |
- writer.emitEnumValue(value.getName()); | |
+ writer.emitEnumValue(value.getName(), (index == enumType.getValues().size() - 1)); | |
+ index++; | |
+ } | |
+ | |
+ // Output Enum Integer Value | |
+ for (EnumType.Value value : enumType.getValues()) { | |
+ String fieldName = value.getName(); | |
+ String initialValue = Integer.toString(value.getTag()); | |
+ writer.emitField("Integer", fieldName.toUpperCase(Locale.US) + "_VALUE", | |
+ EnumSet.of(PUBLIC, STATIC, FINAL), initialValue); | |
} | |
writer.endType(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment