本文整理汇总了Java中com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Type方法的典型用法代码示例。如果您正苦于以下问题:Java FieldDescriptorProto.Type方法的具体用法?Java FieldDescriptorProto.Type怎么用?Java FieldDescriptorProto.Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.DescriptorProtos.FieldDescriptorProto
的用法示例。
在下文中一共展示了FieldDescriptorProto.Type方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveType
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
/**
* Resolves a type based on the given partial name. This does not assume that the name, as
* obtained from the descriptor, is in absolute form.
*/
private TypeRef resolveType(Location location, FieldDescriptorProto.Type kind, String name) {
TypeRef type;
switch (kind) {
case TYPE_MESSAGE:
case TYPE_ENUM:
case TYPE_GROUP:
type = symbolTable.resolveType(namespaces.peek(), name);
break;
default:
type = TypeRef.of(kind);
}
if (type == null) {
model.getDiagReporter().report(Diag.error(location, "Unresolved type '%s'", name));
}
return type;
}
示例2: testFieldTypeEnumMapping
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public void testFieldTypeEnumMapping() throws Exception {
assertEquals(FieldDescriptor.Type.values().length,
FieldDescriptorProto.Type.values().length);
for (FieldDescriptor.Type type : FieldDescriptor.Type.values()) {
FieldDescriptorProto.Type protoType = type.toProto();
assertEquals("TYPE_" + type.name(), protoType.name());
assertEquals(type, FieldDescriptor.Type.valueOf(protoType));
}
}
示例3: isDefaultPackedEncoding
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
/** In proto3, repeated fields of scalar numeric types use packed encoding by default */
private boolean isDefaultPackedEncoding(Field field) {
if (field.getSyntax() == Syntax.SYNTAX_PROTO3 && field.isRepeated()) {
FieldDescriptorProto.Type fieldType = field.getProto().getType();
if (fieldType != FieldDescriptorProto.Type.TYPE_GROUP
&& fieldType != FieldDescriptorProto.Type.TYPE_BYTES
&& fieldType != FieldDescriptorProto.Type.TYPE_STRING
&& fieldType != FieldDescriptorProto.Type.TYPE_MESSAGE) {
return true;
}
}
return false;
}
示例4: addField
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
private void addField(FieldDescriptorProto.Label label, String type, String name, int num, String defaultVal) {
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);
mMsgTypeBuilder.addField(fieldBuilder.build());
}
示例5: setFieldBuilder
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
private FieldDescriptorProto.Builder setFieldBuilder(
final FieldDescriptorProto.Builder fieldBuilder, final String name, final String number,
final String label, final FieldDescriptorProto.Type type) {
return fieldBuilder.setName(name)
.setLabel(FieldDescriptorProto.Label.valueOf("LABEL_" + label.toUpperCase()))
.setNumber(Integer.decode(number)).setType(type);
}
示例6: toType
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
private FieldDescriptorProto.Type toType(Kind kind) {
return FieldDescriptorProto.Type.valueOf(kind.getNumber());
}
示例7: toProto
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public FieldDescriptorProto.Type toProto() {
return FieldDescriptorProto.Type.forNumber(ordinal() + 1);
}
示例8: valueOf
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public static Type valueOf(final FieldDescriptorProto.Type type) {
return values()[type.getNumber() - 1];
}
示例9: toProto
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public FieldDescriptorProto.Type toProto () {
return FieldDescriptorProto.Type.valueOf (ordinal () + 1);
}
示例10: valueOf
import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public static Type valueOf (final FieldDescriptorProto.Type type) {
return values ()[type.getNumber () - 1];
}