Class HalConfiguration

java.lang.Object
org.springframework.hateoas.mediatype.hal.HalConfiguration

public class HalConfiguration extends Object
HAL specific configuration.
Author:
Greg Turnquist, Oliver Drotbohm
  • Constructor Details

    • HalConfiguration

      public HalConfiguration()
      Creates a new default HalConfiguration rendering single links as immediate sub-document.
  • Method Details

    • withRenderSingleLinksFor

      public HalConfiguration withRenderSingleLinksFor(LinkRelation relation, HalConfiguration.RenderSingleLinks renderSingleLinks)
      Configures how to render a single link for a given particular LinkRelation. This will override what has been configured via withRenderSingleLinks(RenderSingleLinks) for that particular link relation.
      Parameters:
      relation - must not be null.
      renderSingleLinks - must not be null.
      Returns:
    • withRenderSingleLinksFor

      public HalConfiguration withRenderSingleLinksFor(String pattern, HalConfiguration.RenderSingleLinks renderSingleLinks)
      Configures how to render a single link for the given link relation pattern, i.e. this can be either a fixed link relation (like search), take wildcards to e.g. match links of a given curie (like acme:*) or even complete URIs (like https://api.acme.com/foo/**).
      Parameters:
      pattern - must not be null or empty.
      renderSingleLinks - must not be null.
      Returns:
      See Also:
    • withRenderSingleLinks

      public HalConfiguration withRenderSingleLinks(HalConfiguration.RenderSingleLinks renderSingleLinks)
      Create a new HalConfiguration by copying the attributes and replacing the renderSingleLinks.
      Parameters:
      renderSingleLinks - must not be null.
      Returns:
      will never be null.
    • withApplyPropertyNamingStrategy

      public HalConfiguration withApplyPropertyNamingStrategy(boolean applyPropertyNamingStrategy)
      Create a new HalConfiguration by copying the attributes and replacing the applyProperNamingStrategy.
      Parameters:
      applyPropertyNamingStrategy -
      Returns:
    • withEnforceEmbeddedCollections

      public HalConfiguration withEnforceEmbeddedCollections(boolean enforceEmbeddedCollections)
      Create a new HalConfiguration by copying the attributes and replacing the enforceEmbeddedCollections.
      Parameters:
      enforceEmbeddedCollections -
      Returns:
    • withObjectMapperCustomizer

      public HalConfiguration withObjectMapperCustomizer(Consumer<com.fasterxml.jackson.databind.ObjectMapper> objectMapperCustomizer)
      Configures an ObjectMapper customizer to tweak the instance after it has been pre-configured with all HAL specific setup.
      Parameters:
      objectMapperCustomizer - must not be null.
      Returns:
      will never be null.
    • withMediaType

      public HalConfiguration withMediaType(MediaType mediaType)
      Registers additional media types that are supposed to be aliases to MediaTypes.HAL_JSON. Registered MediaTypes will be preferred over the default one, i.e. they'll be listed first in client's accept headers etc.
      Parameters:
      mediaType - must not be null.
      Returns:
      will never be null.
      Since:
      1.3
    • getRenderSingleLinks

      public HalConfiguration.RenderSingleLinks getRenderSingleLinks()
    • isApplyPropertyNamingStrategy

      public boolean isApplyPropertyNamingStrategy()
    • isEnforceEmbeddedCollections

      public boolean isEnforceEmbeddedCollections()
    • customize

      public HalConfiguration customize(com.fasterxml.jackson.databind.ObjectMapper mapper)