当前位置: 首页>>代码示例>>Java>>正文


Java FieldDescriptorProto.Type方法代码示例

本文整理汇总了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;
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:21,代码来源:ReferenceResolver.java

示例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));
  }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:10,代码来源:DescriptorsTest.java

示例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;
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:14,代码来源:DescriptorNormalizer.java

示例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());
}
 
开发者ID:os72,项目名称:protobuf-dynamic,代码行数:10,代码来源:MessageDefinition.java

示例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);
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:8,代码来源:ProtoFileParser.java

示例6: toType

import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
private FieldDescriptorProto.Type toType(Kind kind) {
  return FieldDescriptorProto.Type.valueOf(kind.getNumber());
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:4,代码来源:DescriptorGenerator.java

示例7: toProto

import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public FieldDescriptorProto.Type toProto() {
  return FieldDescriptorProto.Type.forNumber(ordinal() + 1);
}
 
开发者ID:yeriomin,项目名称:play-store-api,代码行数:4,代码来源:Descriptors.java

示例8: valueOf

import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public static Type valueOf(final FieldDescriptorProto.Type type) {
  return values()[type.getNumber() - 1];
}
 
开发者ID:yeriomin,项目名称:play-store-api,代码行数:4,代码来源:Descriptors.java

示例9: toProto

import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public FieldDescriptorProto.Type toProto () {
    return FieldDescriptorProto.Type.valueOf (ordinal () + 1);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:4,代码来源:Descriptors.java

示例10: valueOf

import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
public static Type valueOf (final FieldDescriptorProto.Type type) {
    return values ()[type.getNumber () - 1];
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:4,代码来源:Descriptors.java


注:本文中的com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。