Class HalConfiguration
java.lang.Object
org.springframework.hateoas.mediatype.hal.HalConfiguration
HAL specific configuration.
- Author:
- Greg Turnquist, Oliver Drotbohm
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumConfiguration option how to render single links of a givenLinkRelation. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new defaultHalConfigurationrendering single links as immediate sub-document. -
Method Summary
Modifier and TypeMethodDescriptioncustomize(com.fasterxml.jackson.databind.ObjectMapper mapper) booleanbooleanwithApplyPropertyNamingStrategy(boolean applyPropertyNamingStrategy) Create a newHalConfigurationby copying the attributes and replacing the applyProperNamingStrategy.withEnforceEmbeddedCollections(boolean enforceEmbeddedCollections) Create a newHalConfigurationby copying the attributes and replacing the enforceEmbeddedCollections.withMediaType(MediaType mediaType) Registers additional media types that are supposed to be aliases toMediaTypes.HAL_JSON.withObjectMapperCustomizer(Consumer<com.fasterxml.jackson.databind.ObjectMapper> objectMapperCustomizer) Configures anObjectMappercustomizer to tweak the instance after it has been pre-configured with all HAL specific setup.withRenderSingleLinks(HalConfiguration.RenderSingleLinks renderSingleLinks) Create a newHalConfigurationby copying the attributes and replacing the renderSingleLinks.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 (likesearch), take wildcards to e.g. match links of a given curie (likeacme:*) or even complete URIs (likehttps://api.acme.com/foo/**).withRenderSingleLinksFor(LinkRelation relation, HalConfiguration.RenderSingleLinks renderSingleLinks) Configures how to render a single link for a given particularLinkRelation.
-
Constructor Details
-
HalConfiguration
public HalConfiguration()Creates a new defaultHalConfigurationrendering 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 particularLinkRelation. This will override what has been configured viawithRenderSingleLinks(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 (likesearch), take wildcards to e.g. match links of a given curie (likeacme:*) or even complete URIs (likehttps://api.acme.com/foo/**).- Parameters:
pattern- must not be null or empty.renderSingleLinks- must not be null.- Returns:
- See Also:
-
withRenderSingleLinks
Create a newHalConfigurationby copying the attributes and replacing the renderSingleLinks.- Parameters:
renderSingleLinks- must not be null.- Returns:
- will never be null.
-
withApplyPropertyNamingStrategy
Create a newHalConfigurationby copying the attributes and replacing the applyProperNamingStrategy.- Parameters:
applyPropertyNamingStrategy-- Returns:
-
withEnforceEmbeddedCollections
Create a newHalConfigurationby copying the attributes and replacing the enforceEmbeddedCollections.- Parameters:
enforceEmbeddedCollections-- Returns:
-
withObjectMapperCustomizer
public HalConfiguration withObjectMapperCustomizer(Consumer<com.fasterxml.jackson.databind.ObjectMapper> objectMapperCustomizer) Configures anObjectMappercustomizer 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
Registers additional media types that are supposed to be aliases toMediaTypes.HAL_JSON. RegisteredMediaTypes 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
-
isApplyPropertyNamingStrategy
public boolean isApplyPropertyNamingStrategy() -
isEnforceEmbeddedCollections
public boolean isEnforceEmbeddedCollections() -
customize
-