Class JsonApiConfiguration
- java.lang.Object
-
- com.toedter.spring.hateoas.jsonapi.JsonApiConfiguration
-
public class JsonApiConfiguration extends java.lang.ObjectJSON: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 JsonApiConfigurationcustomize(com.fasterxml.jackson.databind.ObjectMapper objectMapper)Customizes the object mapper if a customizer was set with withObjectMapperCustomizer.java.lang.Class<?>getClassForType(java.lang.String type)Returns the class for a given type, when the class was added withwithTypeForClass(Class, String).java.lang.StringgetTypeForClass(java.lang.Class<?> clazz)Returns the JSON:API resource object type for a given class, when it was added withwithTypeForClass(Class, String).booleanisJsonApiVersionRendered()Indicates if the JSON:API version is rendered.booleanisLowerCasedTypeRendered()Indicates if the JSON:API type attribute of resource objects is lower-cased.booleanisPageMetaAutomaticallyCreated()Indicates if page metadata (rendered as top level JSON:API meta) for a paged model is created automatically.booleanisPluralizedTypeRendered()Indicates if the JSON:API type attribute of resource objects is pluralized.booleanisTypeForClassUsedForDeserialization()Indicates if the Java class to JSON:API mapping created withJsonApiConfigurationJsonApiConfigurationwithJsonApiVersionRendered(boolean jsonApiVersionRendered)Indicates if the JSON:API version is rendered.JsonApiConfigurationwithLowerCasedTypeRendered(boolean lowerCasedTypeRendered)Indicates if the JSON:API type attribute of resource objects is lower-cased.JsonApiConfigurationwithObjectMapperCustomizer(java.util.function.Consumer<com.fasterxml.jackson.databind.ObjectMapper> objectMapperCustomizer)You can pass a lambda expression to customize the ObjectMapper used for serialization.JsonApiConfigurationwithPageMetaAutomaticallyCreated(boolean pageMetaAutomaticallyCreated)Indicates if page metadata (rendered as top level JSON:API meta) for a paged model is created automatically.JsonApiConfigurationwithPluralizedTypeRendered(boolean pluralizedTypeRendered)Indicates if the JSON:API type attribute of resource objects is pluralized.JsonApiConfigurationwithTypeForClass(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.JsonApiConfigurationwithTypeForClassUsedForDeserialization(boolean typeForClassUsedForDeserialization)Indicates if the Java class to JSON:API mapping created withJsonApiConfiguration
-
-
-
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.
-
getClassForType
@Nullable public java.lang.Class<?> getClassForType(java.lang.String type)
Returns the class for a given type, when the class was added withwithTypeForClass(Class, String).- Parameters:
type- 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
thisif 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
thisif 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
thisif 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 metadata (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
thisif an identical value is passed).
-
isPageMetaAutomaticallyCreated
public boolean isPageMetaAutomaticallyCreated()
Indicates if page metadata (rendered as top level JSON:API meta) for a paged model is created automatically.- Returns:
- The default is true.
-
withTypeForClassUsedForDeserialization
public JsonApiConfiguration withTypeForClassUsedForDeserialization(boolean typeForClassUsedForDeserialization)
Indicates if the Java class to JSON:API mapping created withJsonApiConfiguration- Parameters:
typeForClassUsedForDeserialization- The new value of this configuration's typeForClassUsedForDeserialization- Returns:
- a clone of this object, except with this updated property (returns
thisif an identical value is passed).
-
isTypeForClassUsedForDeserialization
public boolean isTypeForClassUsedForDeserialization()
Indicates if the Java class to JSON:API mapping created withJsonApiConfiguration- Returns:
- The default is false.
-
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
thisif an identical value is passed).
-
-