com.google.protobuf.DescriptorProtos.EnumValueOptions Java Examples
The following examples show how to use
com.google.protobuf.DescriptorProtos.EnumValueOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtoTypeAdapter.java From gson with Apache License 2.0 | 5 votes |
private Builder(EnumSerialization enumSerialization, CaseFormat fromFieldNameFormat, CaseFormat toFieldNameFormat) { this.serializedNameExtensions = new HashSet<Extension<FieldOptions, String>>(); this.serializedEnumValueExtensions = new HashSet<Extension<EnumValueOptions, String>>(); setEnumSerialization(enumSerialization); setFieldNameSerializationFormat(fromFieldNameFormat, toFieldNameFormat); }
Example #2
Source File: ProtoTypeAdapter.java From gson with Apache License 2.0 | 5 votes |
private ProtoTypeAdapter(EnumSerialization enumSerialization, CaseFormat protoFormat, CaseFormat jsonFormat, Set<Extension<FieldOptions, String>> serializedNameExtensions, Set<Extension<EnumValueOptions, String>> serializedEnumValueExtensions) { this.enumSerialization = enumSerialization; this.protoFormat = protoFormat; this.jsonFormat = jsonFormat; this.serializedNameExtensions = serializedNameExtensions; this.serializedEnumValueExtensions = serializedEnumValueExtensions; }
Example #3
Source File: ProtoTypeAdapter.java From gson with Apache License 2.0 | 5 votes |
/** * Retrieves the custom enum value name from the given options, and if not found, returns the * specified default value. */ private String getCustSerializedEnumValue(EnumValueOptions options, String defaultValue) { for (Extension<EnumValueOptions, String> extension : serializedEnumValueExtensions) { if (options.hasExtension(extension)) { return options.getExtension(extension); } } return defaultValue; }
Example #4
Source File: DescriptorGenerator.java From api-compiler with Apache License 2.0 | 4 votes |
private EnumValueOptions generateEnumValueOptions(EnumValue value) { EnumValueOptions.Builder builder = EnumValueOptions.newBuilder(); setOptions(builder, value.getOptionsList(), ENUM_VALUE_OPTION_NAME_PREFIX); return builder.build(); }
Example #5
Source File: Descriptors.java From play-store-api with GNU General Public License v3.0 | 2 votes |
/** * Get the {@code EnumValueOptions}, defined in {@code descriptor.proto}. */ public EnumValueOptions getOptions() { return proto.getOptions(); }
Example #6
Source File: ProtoTypeAdapter.java From gson with Apache License 2.0 | 2 votes |
/** * Adds an enum value proto annotation that, when set, overrides the default <b>enum</b> value * serialization/deserialization of this adapter. For example, if you add the ' * {@code serialized_value}' annotation and you define an enum in your proto like the one below: * * <pre> * enum MyEnum { * UNKNOWN = 0; * CLIENT_APP_ID = 1 [(serialized_value) = "APP_ID"]; * TWO = 2 [(serialized_value) = "2"]; * } * </pre> * * ...the adapter will serialize the value {@code CLIENT_APP_ID} as "{@code APP_ID}" and the * value {@code TWO} as "{@code 2}". This works for both serialization and deserialization. * <p> * Note that you need to set the enum serialization of this adapter to * {@link EnumSerialization#NAME}, otherwise these annotations will be ignored. */ public Builder addSerializedEnumValueExtension( Extension<EnumValueOptions, String> serializedEnumValueExtension) { serializedEnumValueExtensions.add(checkNotNull(serializedEnumValueExtension)); return this; }