Class 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 ObjectMapper used for converting Java objects to and from JSON. It sets date formats, handles version-aware properties, and configures deserialization of LocalDateTime.

    Author:
    nikritikos
    • 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
    • Constructor Detail

      • APIRestConfigurator

        public APIRestConfigurator()
        Default constructor that configures the ObjectMapper with custom settings.
    • Method Detail

      • parseDateString

        public static Date parseDateString​(String date)
        Parses a string representing a date into a Date object.
        Parameters:
        date - The date string to parse.
        Returns:
        The parsed Date object.
        Throws:
        IllegalStateException - If the date cannot be parsed.
      • parseStringDate

        public static String parseStringDate​(Date date)
        Converts a Date object to a string in the specified date format.
        Parameters:
        date - The Date object to format.
        Returns:
        The formatted date string.
      • getContext

        public com.fasterxml.jackson.databind.ObjectMapper getContext​(Class<?> type)
        Returns the configured ObjectMapper instance used for JSON processing.
        Specified by:
        getContext in interface javax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>
        Parameters:
        type - The class type to resolve.
        Returns:
        The configured ObjectMapper instance.