Class EthosRequestConverter<T>

  • Type Parameters:
    T - The generic type to convert from.

    public class EthosRequestConverter<T>
    extends Object
    Converts request body generic type objects into JSON formatted strings, for use when making POST or PUT API requests.
    • Constructor Detail

      • EthosRequestConverter

        public EthosRequestConverter()
        No-arg constructor which also builds the objectMapper.
    • Method Detail

      • toJsonString

        public String toJsonString​(T genericType)
                            throws com.fasterxml.jackson.core.JsonProcessingException
        Converts the given generic object type to a JSON formatted string. Intended to be used for converting a generic object type of a request body into a JSON formatted string.
        Parameters:
        genericType - The generic object type of the request body to convert.
        Returns:
        A JSON formatted request body string representing the given generic object type, or null of the genericType is null.
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException - Thrown if the objectMapper cannot write the generic type as a string.