code: public static ProtocolSerializer getProtocolSerializer(ProtocolHeader header, Protocol protocol) throws JsonGenerationException, JsonMappingException, IOException{
          final String s = serializeProtocol(header, protocol);
          return new ProtocolSerializer(){
  
              @Override
              public String serializerAsString() {
                  return s;
              }
  
          };
      }
docs: Serialize the Protocol.
  
  @param header
  the ProtocolHeader.
  @param protocol
  the Protocol.
  @return
  the ProtocolSerializer.
  @throws JsonGenerationException
  @throws JsonMappingException
  @throws IOException