code: public static <T extends Serializable> ThriftEnvelopeEvent extractEvent(final String eventName, final DateTime eventDateTime, final T thriftObject)
      {
          final List<ThriftField> thriftFieldList = new ArrayList<ThriftField>();
  
          final Field[] fields = thriftObject.getClass().getFields();
          for (int i = 0; i < fields.length; i++) {
              try {
                  // Thrift fields start at 1, not 0
                  final ThriftField field = ThriftField.createThriftField(fields[i].getType(), fields[i].get(thriftObject), (short) (i + 1));
  
                  // null for the Thrift metaData map and potential other non-supported attributes added by the caller in the thriftObject
                  if (field != null) {
                      thriftFieldList.add(field);
                  }
              }
              catch (IllegalAccessException ignored) {
              }
          }
  
          final ThriftEnvelope envelope = new ThriftEnvelope(eventName, thriftFieldList);
          return new ThriftEnvelopeEvent(eventDateTime, envelope);
      }
docs: Given a generic thrift object (class generated by the thrift compiler), create a ThriftEnvelopeEvent.
  
  @param eventName     Thrift schema name
  @param eventDateTime the event timestamp
  @param thriftObject  Thrift instance
  @param <T>           any Thrift class generated by the thrift compiler
  @return ThriftEnvelopeEvent which wraps all thrift fields as ThriftFields