Package com.microsoft.rest.serializer
Class JacksonAdapter
- java.lang.Object
-
- com.microsoft.rest.serializer.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 aroundJacksonConverterFactoryandObjectMapper.
-
-
Constructor Summary
Constructors Constructor Description JacksonAdapter()Creates a new JacksonAdapter instance with default mapper settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.microsoft.rest.serializer.JacksonConverterFactoryconverterFactory()<T> Tdeserialize(String value, Type type)Deserializes a string into aSerializerAdapterobject using the currentSerializerAdapter.Stringserialize(Object object)Serializes an object into a JSON string.StringserializeList(List<?> list, CollectionFormat format)Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.com.fasterxml.jackson.databind.ObjectMapperserializer()StringserializeRaw(Object object)Serializes an object into a raw string.protected com.fasterxml.jackson.databind.ObjectMappersimpleMapper()Gets a static instance ofObjectMapperthat doesn't handle flattening.
-
-
-
Method Detail
-
simpleMapper
protected com.fasterxml.jackson.databind.ObjectMapper simpleMapper()
Gets a static instance ofObjectMapperthat doesn't handle flattening.- Returns:
- an instance of
ObjectMapper.
-
serializer
public com.fasterxml.jackson.databind.ObjectMapper serializer()
- Specified by:
serializerin interfaceSerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>- Returns:
- the adapted original serializer
-
converterFactory
public com.microsoft.rest.serializer.JacksonConverterFactory converterFactory()
- Specified by:
converterFactoryin interfaceSerializerAdapter<com.fasterxml.jackson.databind.ObjectMapper>- Returns:
- a converter factory for Retrofit
-
serialize
public String serialize(Object object) throws IOException
Description copied from interface:SerializerAdapterSerializes an object into a JSON string.- Specified by:
serializein interfaceSerializerAdapter<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:SerializerAdapterSerializes an object into a raw string. The leading and trailing quotes will be trimmed.- Specified by:
serializeRawin interfaceSerializerAdapter<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:SerializerAdapterSerializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.- Specified by:
serializeListin interfaceSerializerAdapter<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:SerializerAdapterDeserializes a string into aSerializerAdapterobject using the currentSerializerAdapter.- Specified by:
deserializein interfaceSerializerAdapter<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
-
-