com.google.protobuf.Extension Java Examples
The following examples show how to use
com.google.protobuf.Extension.
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 field name from the given options, and if not found, returns the specified * default name. */ private String getCustSerializedName(FieldOptions options, String defaultName) { for (Extension<FieldOptions, String> extension : serializedNameExtensions) { if (options.hasExtension(extension)) { return options.getExtension(extension); } } return protoFormat.to(jsonFormat, defaultName); }
Example #4
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 #5
Source File: PseudoAction.java From bazel with Apache License 2.0 | 5 votes |
public PseudoAction( UUID uuid, ActionOwner owner, NestedSet<Artifact> inputs, Collection<Artifact> outputs, String mnemonic, Extension<ExtraActionInfo, InfoType> infoExtension, InfoType info) { super(owner, inputs, outputs); this.uuid = uuid; this.mnemonic = mnemonic; this.infoExtension = infoExtension; this.info = info; }
Example #6
Source File: Method.java From api-compiler with Apache License 2.0 | 4 votes |
/** * Returns a method-level annotation, or null if it is a stream. */ public <T extends Message> T getMethodAnnotation(Extension<MethodOptions, T> extension) { return methodProto.getOptions().getExtension(extension); }
Example #7
Source File: ProtoTypeAdapter.java From gson with Apache License 2.0 | 2 votes |
/** * Adds a field proto annotation that, when set, overrides the default field name * serialization/deserialization. For example, if you add the '{@code serialized_name}' * annotation and you define a field in your proto like the one below: * * <pre> * string client_app_id = 1 [(serialized_name) = "appId"]; * </pre> * * ...the adapter will serialize the field using '{@code appId}' instead of the default ' * {@code clientAppId}'. This lets you customize the name serialization of any proto field. */ public Builder addSerializedNameExtension( Extension<FieldOptions, String> serializedNameExtension) { serializedNameExtensions.add(checkNotNull(serializedNameExtension)); return this; }
Example #8
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; }