docs: @SuppressWarnings({ "rawtypes", "unchecked" })
      public static void setPropertiesFromThrift(String prefix, Properties properties, org.apache.thrift.TBase entity) throws Exception {
          Field field = entity.getClass().getDeclaredField("metaDataMap");
          Map<org.apache.thrift.TFieldIdEnum, org.apache.thrift.meta_data.FieldMetaData> fields = (Map<org.apache.thrift.TFieldIdEnum, FieldMetaData>) field.get(entity);
          
          for (Entry<org.apache.thrift.TFieldIdEnum, FieldMetaData> f : fields.entrySet()) { 
              ThriftTypes type = ThriftTypes.values()[f.getValue().valueMetaData.type];
              Object value = entity.getFieldValue(f.getKey());
              if (value == null)
                  continue;
              
              switch (type) {
              case VOID   : 
                  break;
              case BOOL   :
              case BYTE   :
              case DOUBLE :
              case I16    :
              case I32    :
              case I64    :
              case STRING :
              case ENUM   : 
                  if (value instanceof byte[]) {
                      properties.put(prefix + f.getKey().getFieldName(), Base64.encodeBase64String((byte[])value));
                  }
                  else if (value instanceof ByteBuffer) {
                      properties.put(prefix + f.getKey().getFieldName(), base64Encode((ByteBuffer)value));
                  }
                  else {
                      properties.put(prefix + f.getKey().getFieldName(), value.toString());
                  }
                  break;
              case MAP    : {
                  String newPrefix = prefix + f.getKey().getFieldName() + ".";
                  org.apache.thrift.meta_data.MapMetaData meta = (org.apache.thrift.meta_data.MapMetaData)f.getValue().valueMetaData;
                  if (!meta.keyMetaData.isStruct() && !meta.keyMetaData.isContainer()) {
                      Map<Object, Object> map = (Map<Object, Object>)value;
                      for (Entry<Object, Object> entry : map.entrySet()) {
                          properties.put(newPrefix + entry.getKey(), entry.getValue().toString());
                      }
                  }
                  else {
                      LOG.error(String.format("Unable to serializer field '%s' key type '%s' not supported", f.getKey().getFieldName(), meta.keyMetaData.getTypedefName()));
                  }
                  break;
              }
              case LIST   : {
                  String newPrefix = prefix + f.getKey().getFieldName() + ".";
  
                  List<Object> list = (List<Object>)value;
                  org.apache.thrift.meta_data.ListMetaData listMeta = (org.apache.thrift.meta_data.ListMetaData)f.getValue().valueMetaData;
                  for (Object entry : list) {
                      String id;
                      if (entry instanceof CfDef) {
                          id = ((CfDef)entry).name;
                      }
                      else if (entry instanceof ColumnDef) {
                          ByteBuffer name = ((ColumnDef)entry).name;
                          id = base64Encode(name);
                      }
                      else {
                          LOG.error("Don't know how to convert to properties " + listMeta.elemMetaData.getTypedefName());
                          continue;
                      }
                      
                      if (listMeta.elemMetaData.isStruct()) {
                          setPropertiesFromThrift(newPrefix + id + ".", properties, (org.apache.thrift.TBase)entry);
                      }
                      else {
                          properties.put(newPrefix + id, entry);
                      }
                  }
                  
                  break;
              }
              case STRUCT : {
                  setPropertiesFromThrift(prefix + f.getKey().getFieldName() + ".", properties, (org.apache.thrift.TBase)value);
                  break;
              }
              case SET    :
              default:
                  LOG.error("Unhandled value : " + f.getKey().getFieldName() + " " + type);
                  break;
              }
          }