com.google.protobuf.Descriptors.FieldDescriptor#Type ( )源码实例Demo

下面列出了com.google.protobuf.Descriptors.FieldDescriptor#Type ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: j2objc   文件: CompatibilityTest.java
public void testFindFieldByNumber() throws Exception {
  Descriptor descriptor = TypicalData.Builder.getDescriptor();
  Collection<FieldDescriptor> fields = descriptor.getFields();
  for (FieldDescriptor field : fields) {
    FieldDescriptor.Type type = field.getType();
    int fieldId = field.getNumber();
    switch (fieldId) {
      case 1:
        assertEquals(Type.INT32, type);
        break;
      case 2:
        assertEquals(Type.BYTES, type);
        break;
      case 3:
        assertEquals(Type.ENUM, type);
        break;
    }
    FieldDescriptor result = descriptor.findFieldByNumber(fieldId);
    assertEquals(field.getNumber(), result.getNumber());
    assertEquals(field.getName(), result.getName());
  }
}
 
源代码2 项目: sql-layer   文件: ProtobufDecompiler.java
protected String literal(Object value, FieldDescriptor.Type type) {
    switch (type) {
    case STRING:
        return quotedString((String)value);
    default:
        return value.toString();
    }
}
 
源代码3 项目: travelguide   文件: DescriptorsTest.java
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));
  }
}
 
源代码4 项目: travelguide   文件: DescriptorsTest.java
/**
 * Test that the FieldDescriptor.Type enum is the same as the
 * WireFormat.FieldType enum.
 */
public void testFieldTypeTablesMatch() throws Exception {
  FieldDescriptor.Type[] values1 = FieldDescriptor.Type.values();
  WireFormat.FieldType[] values2 = WireFormat.FieldType.values();

  assertEquals(values1.length, values2.length);

  for (int i = 0; i < values1.length; i++) {
    assertEquals(values1[i].toString(), values2[i].toString());
  }
}
 
源代码5 项目: curiostack   文件: ProtoFieldInfo.java
/**
 * Returns the {@link Type} of the actual value of this field, which for map fields is the type of
 * the map's value.
 */
FieldDescriptor.Type valueType() {
  return valueField().descriptor().getType();
}