private Type thriftTypeToProtoType()

in core/src/main/java/com/twitter/elephantbird/util/ThriftToDynamicProto.java [542:581]


  private Type thriftTypeToProtoType(Field tField) {
    byte thriftType = tField.getType();
    switch (thriftType)  {
      case TType.BOOL:
        return Type.TYPE_BOOL;
      case TType.BYTE:
        return Type.TYPE_INT32;
      case TType.DOUBLE:
        return Type.TYPE_DOUBLE;
      case TType.I16:
        return Type.TYPE_INT32;
      case TType.I32:
        return Type.TYPE_INT32;
      case TType.I64:
        return Type.TYPE_INT64;
      case TType.STRING:
        // Thrift thinks bytes and strings are interchangeable. Protocol buffers are not insane.
        return tField.isBuffer() ? Type.TYPE_BYTES : Type.TYPE_STRING;
      case TType.ENUM:
        // TODO: proper enum handling. For now, convert to strings.
        return Type.TYPE_STRING;
      case TType.STRUCT:
        if (supportNestedObjects) { return Type.TYPE_MESSAGE; }
        return null;
      case TType.MAP:
        return null;
      case TType.SET:
        return null;
      case TType.LIST:
        return null;
      default:
        if (ignoreUnsupportedTypes) {
          LOG.warn("Thrift type " + thriftType + " not supported for field "
             + tField.getName() + ". Ignoring");
          return null;
        }
        throw new IllegalArgumentException("Can't map Thrift type " + thriftType
          + " to a Protobuf type for field: " + tField.getName());
    }
  }