Class JacksonAdapter

  • All Implemented Interfaces:
    SerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>

    public class JacksonAdapter
    extends Object
    implements SerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>
    A serialization helper class wrapped around JacksonConverterFactory and ObjectMapper.
    • Constructor Detail

      • JacksonAdapter

        public JacksonAdapter()
        Creates a new JacksonAdapter instance with default mapper settings.
    • Method Detail

      • simpleMapper

        protected com.fasterxml.jackson.databind.ObjectMapper simpleMapper()
        Gets a static instance of ObjectMapper that doesn't handle flattening.
        Returns:
        an instance of ObjectMapper.
      • serializer

        public com.fasterxml.jackson.databind.ObjectMapper serializer()
        Specified by:
        serializer in interface SerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>
        Returns:
        the adapted original serializer
      • converterFactory

        public com.microsoft.rest.serializer.JacksonConverterFactory converterFactory()
        Specified by:
        converterFactory in interface SerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>
        Returns:
        a converter factory for Retrofit
      • serialize

        public String serialize​(Object object)
                         throws IOException
        Description copied from interface: SerializerAdapter
        Serializes an object into a JSON string.
        Specified by:
        serialize in interface SerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>
        Parameters:
        object - the object to serialize.
        Returns:
        the serialized string. Null if the object to serialize is null.
        Throws:
        IOException - exception from serialization.
      • serializeRaw

        public String serializeRaw​(Object object)
        Description copied from interface: SerializerAdapter
        Serializes an object into a raw string. The leading and trailing quotes will be trimmed.
        Specified by:
        serializeRaw in interface SerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>
        Parameters:
        object - the object to serialize.
        Returns:
        the serialized string. Null if the object to serialize is null.
      • serializeList

        public String serializeList​(List<?> list,
                                    CollectionFormat format)
        Description copied from interface: SerializerAdapter
        Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.
        Specified by:
        serializeList in interface SerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>
        Parameters:
        list - the list to serialize.
        format - the Swagger collection format.
        Returns:
        the serialized string
      • deserialize

        public <T> T deserialize​(String value,
                                 Type type)
                          throws IOException
        Description copied from interface: SerializerAdapter
        Deserializes a string into a SerializerAdapter object using the current SerializerAdapter.
        Specified by:
        deserialize in interface SerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>
        Type Parameters:
        T - the type of the deserialized object.
        Parameters:
        value - the string value to deserialize.
        type - the type to deserialize.
        Returns:
        the deserialized object.
        Throws:
        IOException - exception in deserialization