/** * This implementation sets the default headers by calling {@link #addDefaultHeaders}, * and then calls {@link #writeInternal}. */ public final void write(final T t, @Nullable final Type type, @Nullable MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { final HttpHeaders headers = outputMessage.getHeaders(); addDefaultHeaders(headers, t, contentType); if (outputMessage instanceof StreamingHttpOutputMessage) { StreamingHttpOutputMessage streamingOutputMessage = (StreamingHttpOutputMessage) outputMessage; streamingOutputMessage.setBody(outputStream -> writeInternal(t, type, new HttpOutputMessage() { @Override public OutputStream getBody() { return outputStream; } @Override public HttpHeaders getHeaders() { return headers; } })); } else { writeInternal(t, type, outputMessage); outputMessage.getBody().flush(); } }
@Override public boolean canWrite(@Nullable Type type, Class<?> clazz, @Nullable MediaType mediaType) { return canWrite(clazz, mediaType); }
@Override @Nullable protected MediaType getDefaultContentType(Object object) throws IOException { if (object instanceof MappingJacksonValue) { object = ((MappingJacksonValue) object).getValue(); } return super.getDefaultContentType(object); }
@Override protected Long getContentLength(Object object, @Nullable MediaType contentType) throws IOException { if (object instanceof MappingJacksonValue) { object = ((MappingJacksonValue) object).getValue(); } return super.getContentLength(object, contentType); }
@Override protected void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { writeInternal(t, null, outputMessage); }
@Override @Nullable protected MediaType getDefaultContentType(Object object) throws IOException { if (object instanceof MappingJacksonValue) { object = ((MappingJacksonValue) object).getValue(); } return super.getDefaultContentType(object); }
@Override protected Long getContentLength(Object object, @Nullable MediaType contentType) throws IOException { if (object instanceof MappingJacksonValue) { object = ((MappingJacksonValue) object).getValue(); } return super.getContentLength(object, contentType); }
@Override protected void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { writeInternal(t, null, outputMessage); }
/** * This implementation sets the default headers by calling {@link #addDefaultHeaders}, * and then calls {@link #writeInternal}. */ public final void write(final T t, @Nullable final Type type, @Nullable MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { final HttpHeaders headers = outputMessage.getHeaders(); addDefaultHeaders(headers, t, contentType); if (outputMessage instanceof StreamingHttpOutputMessage) { StreamingHttpOutputMessage streamingOutputMessage = (StreamingHttpOutputMessage) outputMessage; streamingOutputMessage.setBody(outputStream -> writeInternal(t, type, new HttpOutputMessage() { @Override public OutputStream getBody() { return outputStream; } @Override public HttpHeaders getHeaders() { return headers; } })); } else { writeInternal(t, type, outputMessage); outputMessage.getBody().flush(); } }
@Override public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) { return type instanceof ParameterizedType && super.canRead(type, contextClass, mediaType); }
@Override @Nullable protected MediaType getDefaultContentType(Object object) throws IOException { if (object instanceof MappingJacksonValue) { object = ((MappingJacksonValue) object).getValue(); } return super.getDefaultContentType(object); }
@Override protected Long getContentLength(Object object, @Nullable MediaType contentType) throws IOException { if (object instanceof MappingJacksonValue) { object = ((MappingJacksonValue) object).getValue(); } return super.getContentLength(object, contentType); }
@Override protected void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { writeInternal(t, null, outputMessage); }
@Override public boolean canWrite(@Nullable Type type, Class<?> clazz, @Nullable MediaType mediaType) { return canWrite(clazz, mediaType); }
/** * This implementation sets the default headers by calling {@link #addDefaultHeaders}, * and then calls {@link #writeInternal}. */ public final void write(final T t, @Nullable final Type type, @Nullable MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { final HttpHeaders headers = outputMessage.getHeaders(); addDefaultHeaders(headers, t, contentType); if (outputMessage instanceof StreamingHttpOutputMessage) { StreamingHttpOutputMessage streamingOutputMessage = (StreamingHttpOutputMessage) outputMessage; streamingOutputMessage.setBody(outputStream -> writeInternal(t, type, new HttpOutputMessage() { @Override public OutputStream getBody() { return outputStream; } @Override public HttpHeaders getHeaders() { return headers; } })); } else { writeInternal(t, type, outputMessage); outputMessage.getBody().flush(); } }
@Override @Nullable protected MediaType getDefaultContentType(Object object) throws IOException { if (object instanceof MappingJacksonValue) { object = ((MappingJacksonValue) object).getValue(); } return super.getDefaultContentType(object); }
@Override protected Long getContentLength(Object object, @Nullable MediaType contentType) throws IOException { if (object instanceof MappingJacksonValue) { object = ((MappingJacksonValue) object).getValue(); } return super.getContentLength(object, contentType); }
@Override protected void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { writeInternal(t, null, outputMessage); }