Package com.inteliqua.rest.common
Class APIRestConfigurator
- java.lang.Object
-
- com.inteliqua.rest.common.APIRestConfigurator
-
- All Implemented Interfaces:
javax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>
@Provider public class APIRestConfigurator extends Object implements javax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>
Configures the REST API with custom settings for serializing and deserializing data.This class customizes the
ObjectMapperused for converting Java objects to and from JSON. It sets date formats, handles version-aware properties, and configures deserialization ofLocalDateTime.- Author:
- nikritikos
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPI_DATE_FORMATThe date format used in API requests and responses (ISO 8601).
-
Constructor Summary
Constructors Constructor Description APIRestConfigurator()Default constructor that configures the ObjectMapper with custom settings.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.ObjectMappergetContext(Class<?> type)Returns the configuredObjectMapperinstance used for JSON processing.static DateparseDateString(String date)Parses a string representing a date into aDateobject.static StringparseStringDate(Date date)Converts aDateobject to a string in the specified date format.
-
-
-
Field Detail
-
API_DATE_FORMAT
public static final String API_DATE_FORMAT
The date format used in API requests and responses (ISO 8601).- See Also:
- Constant Field Values
-
-
Method Detail
-
parseDateString
public static Date parseDateString(String date)
Parses a string representing a date into aDateobject.- Parameters:
date- The date string to parse.- Returns:
- The parsed
Dateobject. - Throws:
IllegalStateException- If the date cannot be parsed.
-
parseStringDate
public static String parseStringDate(Date date)
Converts aDateobject to a string in the specified date format.- Parameters:
date- TheDateobject to format.- Returns:
- The formatted date string.
-
getContext
public com.fasterxml.jackson.databind.ObjectMapper getContext(Class<?> type)
Returns the configuredObjectMapperinstance used for JSON processing.- Specified by:
getContextin interfacejavax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>- Parameters:
type- The class type to resolve.- Returns:
- The configured
ObjectMapperinstance.
-
-