// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/MessageResponse.java
// public class MessageResponse {
// 
// 	private String message;
// 
// 	public MessageResponse(String message) {
// 		this.message = message;
// 	}
// 
// 	public String getMessage() {
// 		return message;
// 	}
// }
// 
// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/json/JacksonReaderWriter.java
// public class JacksonReaderWriter implements JsonReader, JsonWriter {
// 
//     private ObjectMapper sharedMapper;
//     private JsonFactory sharedFactory;
// 
//     public JacksonReaderWriter() {
// 
//         // fun Jackson API with circular dependencies ... so we create a mapper
//         // first, and grab implicitly created factory from it
//         this.sharedMapper = new ObjectMapper();
//         this.sharedFactory = sharedMapper.getFactory();
// 
//         // make sure mapper does not attempt closing streams it does not
//         // manage... why is this even a default in jackson?
//         sharedFactory.disable(Feature.AUTO_CLOSE_TARGET);
// 
//         // do not flush every time. why would we want to do that?
//         // this is having a HUGE impact on extrest serializers (5x speedup)
//         sharedMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
//     }
// 
//     private JsonNode parseJson(InputStream jsonStream) {
//         Objects.requireNonNull(jsonStream);
// 
//         try {
//             com.fasterxml.jackson.core.JsonParser parser = sharedFactory.createParser(jsonStream);
//             return new ObjectMapper().readTree(parser);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.BAD_REQUEST, "Error parsing JSON", e);
//         }
//     }
// 
//     @Override
//     public <T> T read(Class<T> type, InputStream jsonStream) {
//         JsonNode jsonNode = parseJson(jsonStream);
//         try {
//             return new ObjectMapper().readValue(new TreeTraversingParser(jsonNode), type);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.BAD_REQUEST, "Error mapping JSON to object", e);
//         }
//     }
// 
//     @Override
//     public void write(OutputStream out, JacksonWriterDelegate delegate) {
//         // TODO: UTF-8 is hardcoded...
//         try (JsonGenerator generator = sharedFactory.createGenerator(out, JsonEncoding.UTF8)) {
//             delegate.write(generator);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.INTERNAL_SERVER_ERROR, "Error writing JSON", e);
//         }
//     }
// 
// }
// 
// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/json/JsonWriter.java
// public interface JsonWriter {
// 
//     void write(OutputStream out, JacksonWriterDelegate delegate);
// }


import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyWriter;
import org.objectstyle.graphql.rest.MessageResponse;
import org.objectstyle.graphql.rest.json.JacksonReaderWriter;
import org.objectstyle.graphql.rest.json.JsonWriter;
package org.objectstyle.graphql.rest.provider;




public class MessageResponseWriter implements MessageBodyWriter<MessageResponse> {
    @Context
    Configuration config;

    @Override
    public long getSize(MessageResponse t, Class<?> type, Type genericType, Annotation[] annotations,
                        MediaType mediaType) {
        return -1;
    }

    @Override
    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
        return MessageResponse.class.isAssignableFrom(type);
    }

    @Override
    public void writeTo(MessageResponse t, Class<?> type, Type genericType, Annotation[] annotations,
                        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
            throws IOException {

// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/MessageResponse.java
// public class MessageResponse {
// 
// 	private String message;
// 
// 	public MessageResponse(String message) {
// 		this.message = message;
// 	}
// 
// 	public String getMessage() {
// 		return message;
// 	}
// }
// 
// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/json/JacksonReaderWriter.java
// public class JacksonReaderWriter implements JsonReader, JsonWriter {
// 
//     private ObjectMapper sharedMapper;
//     private JsonFactory sharedFactory;
// 
//     public JacksonReaderWriter() {
// 
//         // fun Jackson API with circular dependencies ... so we create a mapper
//         // first, and grab implicitly created factory from it
//         this.sharedMapper = new ObjectMapper();
//         this.sharedFactory = sharedMapper.getFactory();
// 
//         // make sure mapper does not attempt closing streams it does not
//         // manage... why is this even a default in jackson?
//         sharedFactory.disable(Feature.AUTO_CLOSE_TARGET);
// 
//         // do not flush every time. why would we want to do that?
//         // this is having a HUGE impact on extrest serializers (5x speedup)
//         sharedMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
//     }
// 
//     private JsonNode parseJson(InputStream jsonStream) {
//         Objects.requireNonNull(jsonStream);
// 
//         try {
//             com.fasterxml.jackson.core.JsonParser parser = sharedFactory.createParser(jsonStream);
//             return new ObjectMapper().readTree(parser);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.BAD_REQUEST, "Error parsing JSON", e);
//         }
//     }
// 
//     @Override
//     public <T> T read(Class<T> type, InputStream jsonStream) {
//         JsonNode jsonNode = parseJson(jsonStream);
//         try {
//             return new ObjectMapper().readValue(new TreeTraversingParser(jsonNode), type);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.BAD_REQUEST, "Error mapping JSON to object", e);
//         }
//     }
// 
//     @Override
//     public void write(OutputStream out, JacksonWriterDelegate delegate) {
//         // TODO: UTF-8 is hardcoded...
//         try (JsonGenerator generator = sharedFactory.createGenerator(out, JsonEncoding.UTF8)) {
//             delegate.write(generator);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.INTERNAL_SERVER_ERROR, "Error writing JSON", e);
//         }
//     }
// 
// }
// 
// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/json/JsonWriter.java
// public interface JsonWriter {
// 
//     void write(OutputStream out, JacksonWriterDelegate delegate);
// }


// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/provider/MessageResponseWriter.java
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyWriter;
import org.objectstyle.graphql.rest.MessageResponse;
import org.objectstyle.graphql.rest.json.JacksonReaderWriter;
import org.objectstyle.graphql.rest.json.JsonWriter;

package org.objectstyle.graphql.rest.provider;




public class MessageResponseWriter implements MessageBodyWriter<MessageResponse> {
    @Context
    Configuration config;

    @Override
    public long getSize(MessageResponse t, Class<?> type, Type genericType, Annotation[] annotations,
                        MediaType mediaType) {
        return -1;
    }

    @Override
    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
        return MessageResponse.class.isAssignableFrom(type);
    }

    @Override
    public void writeTo(MessageResponse t, Class<?> type, Type genericType, Annotation[] annotations,
                        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
            throws IOException {

        JsonWriter writer = (JsonWriter) config.getProperty(JacksonReaderWriter.class.getName());