Class JsonIdAdderBodyReader

  • All Implemented Interfaces:
    javax.ws.rs.ext.MessageBodyReader<Object>

    @Provider
    @Consumes("application/json")
    @Priority(4999)
    public class JsonIdAdderBodyReader
    extends Object
    implements javax.ws.rs.ext.MessageBodyReader<Object>
    Sometimes jackson/resteasy will not unmarshal a json because there is no type information, but the prototype actually specifies it fully. This message body reader will deal with that (using TypeIdResolver.idFromBaseType(), by adding the id implicitly (if it is missing) before the actual unmarshal.
    Since:
    2.7
    Author:
    Michiel Meeuwissen
    • Constructor Detail

      • JsonIdAdderBodyReader

        public JsonIdAdderBodyReader()
    • Method Detail

      • isReadable

        public boolean isReadable​(Class<?> type,
                                  Type genericType,
                                  Annotation[] annotations,
                                  javax.ws.rs.core.MediaType mediaType)
        Specified by:
        isReadable in interface javax.ws.rs.ext.MessageBodyReader<Object>
      • readFrom

        public Object readFrom​(@NonNull Class<Object> type,
                               Type genericType,
                               Annotation[] annotations,
                               javax.ws.rs.core.MediaType mediaType,
                               javax.ws.rs.core.MultivaluedMap<String,​String> httpHeaders,
                               InputStream entityStream)
                        throws javax.ws.rs.WebApplicationException,
                               IOException
        Specified by:
        readFrom in interface javax.ws.rs.ext.MessageBodyReader<Object>
        Throws:
        javax.ws.rs.WebApplicationException
        IOException