Java Code Examples for com.google.protobuf.DescriptorProtos.FieldDescriptorProto#Label
The following examples show how to use
com.google.protobuf.DescriptorProtos.FieldDescriptorProto#Label .
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: MessageDefinition.java From protobuf-dynamic with Apache License 2.0 | 5 votes |
private void addField(FieldDescriptorProto.Label label, String type, String name, int num, String defaultVal, OneofBuilder oneofBuilder) { FieldDescriptorProto.Builder fieldBuilder = FieldDescriptorProto.newBuilder(); fieldBuilder.setLabel(label); FieldDescriptorProto.Type primType = sTypeMap.get(type); if (primType != null) fieldBuilder.setType(primType); else fieldBuilder.setTypeName(type); fieldBuilder.setName(name).setNumber(num); if (defaultVal != null) fieldBuilder.setDefaultValue(defaultVal); if (oneofBuilder != null) fieldBuilder.setOneofIndex(oneofBuilder.getIdx()); mMsgTypeBuilder.addField(fieldBuilder.build()); }
Example 2
Source File: MessageDefinition.java From protobuf-dynamic with Apache License 2.0 | 4 votes |
public Builder addField(String label, String type, String name, int num, String defaultVal) { FieldDescriptorProto.Label protoLabel = sLabelMap.get(label); if (protoLabel == null) throw new IllegalArgumentException("Illegal label: " + label); addField(protoLabel, type, name, num, defaultVal, null); return this; }