Class HalFormsHttpMessageConverter

java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<T>
org.springframework.http.converter.AbstractSmartHttpMessageConverter<Object>
org.springframework.http.converter.AbstractJacksonHttpMessageConverter<tools.jackson.databind.json.JsonMapper>
org.springframework.http.converter.json.JacksonJsonHttpMessageConverter
org.springframework.hateoas.server.mvc.TypeConstrainedJacksonJsonHttpMessageConverter
org.springframework.hateoas.mediatype.hal.forms.HalFormsHttpMessageConverter
All Implemented Interfaces:
org.springframework.http.converter.HttpMessageConverter<Object>, org.springframework.http.converter.SmartHttpMessageConverter<Object>

public class HalFormsHttpMessageConverter extends TypeConstrainedJacksonJsonHttpMessageConverter
A TypeConstrainedMappingJackson2HttpMessageConverter that will inspect the returned RepresentationModel for affordances and flip the MediaType rendered back to MediaTypes.HAL_JSON if no templates have been registered.
Since:
2.4
Author:
Oliver Drotbohm
  • Field Summary

    Fields inherited from class org.springframework.http.converter.AbstractJacksonHttpMessageConverter

    defaultMapper

    Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    HalFormsHttpMessageConverter(org.springframework.beans.factory.BeanFactory factory, tools.jackson.databind.json.JsonMapper mapper)
    Creates a new HalFormsHttpMessageConverter for the given BeanFactory and JsonMapper.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    writeInternal(Object object, org.springframework.core.ResolvableType type, org.springframework.http.HttpOutputMessage outputMessage, @Nullable Map<String,Object> hints)
     

    Methods inherited from class org.springframework.hateoas.server.mvc.TypeConstrainedJacksonJsonHttpMessageConverter

    canRead, canRead, canWrite

    Methods inherited from class org.springframework.http.converter.json.JacksonJsonHttpMessageConverter

    getMediaTypesForProblemDetail, setJsonPrefix, setPrefixJson, writePrefix

    Methods inherited from class org.springframework.http.converter.AbstractJacksonHttpMessageConverter

    customizeReader, customizeWriter, getCharset, getJavaType, getJsonEncoding, getMapper, getMappersForType, getSupportedMediaTypes, read, readInternal, registerMappersForType, setSupportedMediaTypes, supportsRepeatableWrites, writeSuffix

    Methods inherited from class org.springframework.http.converter.AbstractSmartHttpMessageConverter

    canWrite, supports, write, writeInternal

    Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

    addDefaultHeaders, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.http.converter.HttpMessageConverter

    getSupportedMediaTypes

    Methods inherited from interface org.springframework.http.converter.SmartHttpMessageConverter

    read, write
  • Constructor Details

    • HalFormsHttpMessageConverter

      public HalFormsHttpMessageConverter(org.springframework.beans.factory.BeanFactory factory, tools.jackson.databind.json.JsonMapper mapper)
      Creates a new HalFormsHttpMessageConverter for the given BeanFactory and JsonMapper.
      Parameters:
      factory - must not be null.
      mapper - must not be null.
  • Method Details

    • writeInternal

      protected void writeInternal(Object object, org.springframework.core.ResolvableType type, org.springframework.http.HttpOutputMessage outputMessage, @Nullable Map<String,Object> hints) throws IOException, org.springframework.http.converter.HttpMessageNotWritableException
      Overrides:
      writeInternal in class org.springframework.http.converter.AbstractJacksonHttpMessageConverter<tools.jackson.databind.json.JsonMapper>
      Throws:
      IOException
      org.springframework.http.converter.HttpMessageNotWritableException