code: public static SerializationFormat toSerializationFormat(TProtocolFactory protoFactory) {
          requireNonNull(protoFactory, "protoFactory");
  
          if (protoFactory instanceof TBinaryProtocol.Factory) {
              return ThriftSerializationFormats.BINARY;
          } else if (protoFactory instanceof TCompactProtocol.Factory) {
              return ThriftSerializationFormats.COMPACT;
          } else if (protoFactory instanceof TJSONProtocol.Factory) {
              return ThriftSerializationFormats.JSON;
          } else if (protoFactory instanceof TTextProtocol.Factory) {
              return ThriftSerializationFormats.TEXT;
          } else {
              throw new IllegalArgumentException(
                      "unsupported TProtocolFactory: " + protoFactory.getClass().getName());
          }
      }
docs: Returns the {@link SerializationFormat} for the specified {@link TProtocolFactory}.
  
  @throws IllegalArgumentException if the specified {@link TProtocolFactory} is not known by this class