Class JsonApiConfiguration
- java.lang.Object
-
- com.toedter.spring.hateoas.jsonapi.JsonApiConfiguration
-
public class JsonApiConfiguration extends java.lang.Object
JSON:API specific configuration.
-
-
Constructor Summary
Constructors Constructor Description JsonApiConfiguration()
Creates a new defaultJsonApiConfiguration
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonApiConfiguration
customize(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Customizes the object mapper if a customizer was set with withObjectMapperCustomizer.java.lang.String
getTypeForClass(java.lang.Class<?> clazz)
Returns the JSON:API resource object type for a given class, when it was added withwithTypeForClass(Class, String)
.boolean
isJsonApiVersionRendered()
Indicates if the JSON:API version is rendered.boolean
isLowerCasedTypeRendered()
Indicates if the JSON:API type attribute of resource objects is lower-cased.boolean
isPageMetaAutomaticallyCreated()
Indicates if page meta data (rendered as top level JSON:API meta) for a paged model is created automatically.boolean
isPluralizedTypeRendered()
Indicates if the JSON:API type attribute of resource objects is pluralized.JsonApiConfiguration
withJsonApiVersionRendered(boolean jsonApiVersionRendered)
Indicates if the JSON:API version is rendered.JsonApiConfiguration
withLowerCasedTypeRendered(boolean lowerCasedTypeRendered)
Indicates if the JSON:API type attribute of resource objects is lower-cased.JsonApiConfiguration
withObjectMapperCustomizer(java.util.function.Consumer<com.fasterxml.jackson.databind.ObjectMapper> objectMapperCustomizer)
You can pass a lambda expression to customize the ObjectMapper used for serialization.JsonApiConfiguration
withPageMetaAutomaticallyCreated(boolean pageMetaAutomaticallyCreated)
Indicates if page meta data (rendered as top level JSON:API meta) for a paged model is created automatically.JsonApiConfiguration
withPluralizedTypeRendered(boolean pluralizedTypeRendered)
Indicates if the JSON:API type attribute of resource objects is pluralized.JsonApiConfiguration
withTypeForClass(java.lang.Class<?> clazz, java.lang.String type)
Creates a mapping for a given class to get the JSON:API resource object type when rendered.
-
-
-
Constructor Detail
-
JsonApiConfiguration
public JsonApiConfiguration()
Creates a new defaultJsonApiConfiguration
.
-
-
Method Detail
-
customize
public JsonApiConfiguration customize(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Customizes the object mapper if a customizer was set with withObjectMapperCustomizer.- Parameters:
objectMapper
- the object mapper to be customized- Returns:
- this JsonApiConfiguration
-
withTypeForClass
public JsonApiConfiguration withTypeForClass(java.lang.Class<?> clazz, java.lang.String type)
Creates a mapping for a given class to get the JSON:API resource object type when rendered.- Parameters:
clazz
- must not be null.type
- must not be null.- Returns:
- a clone of this object, except with this updated property
-
getTypeForClass
@Nullable public java.lang.String getTypeForClass(java.lang.Class<?> clazz)
Returns the JSON:API resource object type for a given class, when it was added withwithTypeForClass(Class, String)
.- Parameters:
clazz
- must not be null.- Returns:
- can return null.
-
withPluralizedTypeRendered
public JsonApiConfiguration withPluralizedTypeRendered(boolean pluralizedTypeRendered)
Indicates if the JSON:API type attribute of resource objects is pluralized.- Parameters:
pluralizedTypeRendered
- The new value of this configuration's pluralizedTypeRendered- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
isPluralizedTypeRendered
public boolean isPluralizedTypeRendered()
Indicates if the JSON:API type attribute of resource objects is pluralized.- Returns:
- The default is true.
-
withLowerCasedTypeRendered
public JsonApiConfiguration withLowerCasedTypeRendered(boolean lowerCasedTypeRendered)
Indicates if the JSON:API type attribute of resource objects is lower-cased.- Parameters:
lowerCasedTypeRendered
- The new value of this configuration's lowerCasedTypeRendered- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
isLowerCasedTypeRendered
public boolean isLowerCasedTypeRendered()
Indicates if the JSON:API type attribute of resource objects is lower-cased.- Returns:
- The default is true.
-
withJsonApiVersionRendered
public JsonApiConfiguration withJsonApiVersionRendered(boolean jsonApiVersionRendered)
Indicates if the JSON:API version is rendered.If set to true, each rendered JSON:API document will start with
"jsonapi": { "version": "1.0" }
- Parameters:
jsonApiVersionRendered
- The new value of this configuration's jsonApiVersionRendered- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
isJsonApiVersionRendered
public boolean isJsonApiVersionRendered()
Indicates if the JSON:API version is rendered.If set to true, each rendered JSON:API document will start with
"jsonapi": { "version": "1.0" }
- Returns:
- The default is false.
-
withPageMetaAutomaticallyCreated
public JsonApiConfiguration withPageMetaAutomaticallyCreated(boolean pageMetaAutomaticallyCreated)
Indicates if page meta data (rendered as top level JSON:API meta) for a paged model is created automatically.- Parameters:
pageMetaAutomaticallyCreated
- The new value of this configuration's paginationLinksAutomaticallyCreated- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
isPageMetaAutomaticallyCreated
public boolean isPageMetaAutomaticallyCreated()
Indicates if page meta data (rendered as top level JSON:API meta) for a paged model is created automatically.- Returns:
- The default is true.
-
withObjectMapperCustomizer
public JsonApiConfiguration withObjectMapperCustomizer(java.util.function.Consumer<com.fasterxml.jackson.databind.ObjectMapper> objectMapperCustomizer)
You can pass a lambda expression to customize the ObjectMapper used for serialization.- Parameters:
objectMapperCustomizer
- the ObjectMapper customizer- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
-