All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.aequologica.neo.serioulizer.jaxrs.MinimalReaderWriterMessageBody Maven / Gradle / Ivy

The newest version!
package net.aequologica.neo.serioulizer.jaxrs;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;

import com.fasterxml.jackson.core.type.TypeReference;
import net.aequologica.neo.serioulizer.jackson.AbstractReaderWriter;
import net.aequologica.neo.serioulizer.jackson.MinimalReaderWriter;

public class MinimalReaderWriterMessageBody implements MessageBodyWriter, MessageBodyReader {
    
    AbstractReaderWriter theReaderWriter = new MinimalReaderWriter(new TypeReference() {});
    
    @Override
    public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) {
        return true;
    }

    @Override
    public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) {
        return true;
    }

    @Override
    public T readFrom(Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream)
            throws IOException, WebApplicationException {
        return theReaderWriter.read(entityStream);
    }

    @Override
    public void writeTo(T t, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream)
            throws IOException, WebApplicationException {
        theReaderWriter.write(entityStream, t);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy