Package nl.vpro.jackson2.rs
Class JsonIdAdderBodyReader
java.lang.Object
nl.vpro.jackson2.rs.JsonIdAdderBodyReader
- All Implemented Interfaces:
jakarta.ws.rs.ext.MessageBodyReader<Object>
@Provider
@Consumes("application/json")
@Priority(4999)
public class JsonIdAdderBodyReader
extends Object
implements jakarta.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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isReadable
(Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType) readFrom
(@NonNull Class<Object> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType, jakarta.ws.rs.core.MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
-
Constructor Details
-
JsonIdAdderBodyReader
public JsonIdAdderBodyReader()
-
-
Method Details
-
isReadable
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType) - Specified by:
isReadable
in interfacejakarta.ws.rs.ext.MessageBodyReader<Object>
-
readFrom
public Object readFrom(@NonNull Class<Object> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType, jakarta.ws.rs.core.MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws jakarta.ws.rs.WebApplicationException, IOException- Specified by:
readFrom
in interfacejakarta.ws.rs.ext.MessageBodyReader<Object>
- Throws:
jakarta.ws.rs.WebApplicationException
IOException
-