Class JacksonSerder
- java.lang.Object
-
- com.azure.android.core.serde.jackson.JacksonSerder
-
public final class JacksonSerder extends java.lang.ObjectThe type exposes APIs for serialization and deserialization using Jackson.
-
-
Constructor Summary
Constructors Constructor Description JacksonSerder()Creates a new JacksonAdapter instance with default mapper settings.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JacksonSerdercreateDefault()maintain singleton instance of the default serializer adapter.<T> Tdeserialize(java.io.InputStream inputStream, java.lang.reflect.Type type, SerdeEncoding encoding)Deserializes a byte[] into aTobject.<T> Tdeserialize(java.lang.String value, java.lang.reflect.Type type, SerdeEncoding encoding)Deserializes a string into aTobject.<T> Tdeserialize(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.reflect.Type deserializedHeadersType)Deserialize the provided headers returned from a REST API to an entity instance declared as the model to hold 'Matching' headers.java.lang.Stringserialize(java.lang.Object object, SerdeEncoding encoding)Serializes an object into a string.voidserialize(java.lang.Object object, SerdeEncoding encoding, java.io.OutputStream outputStream)Serializes an object and writes its output into anOutputStream.java.lang.StringserializeList(java.util.List<?> list, SerdeCollectionFormat format)Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.java.lang.StringserializeRaw(java.lang.Object object)Serializes an object into a raw string.
-
-
-
Method Detail
-
createDefault
public static JacksonSerder createDefault()
maintain singleton instance of the default serializer adapter.- Returns:
- the default serializer
-
serialize
public java.lang.String serialize(java.lang.Object object, SerdeEncoding encoding) throws java.io.IOExceptionSerializes an object into a string.- Parameters:
object- the object to serializeencoding- the encoding to use for serialization- Returns:
- the serialized string. Null if the object to serialize is null
- Throws:
java.io.IOException- exception from serialization
-
serialize
public void serialize(java.lang.Object object, SerdeEncoding encoding, java.io.OutputStream outputStream) throws java.io.IOExceptionSerializes an object and writes its output into anOutputStream.- Parameters:
object- The object to serialize.encoding- The encoding to use for serialization.outputStream- TheOutputStreamwhere the serialized object will be written.- Throws:
java.io.IOException- exception from serialization
-
serializeRaw
public java.lang.String serializeRaw(java.lang.Object object)
Serializes an object into a raw string. The leading and trailing quotes will be trimmed.- Parameters:
object- the object to serialize- Returns:
- the serialized string. Null if the object to serialize is null
-
serializeList
public java.lang.String serializeList(java.util.List<?> list, SerdeCollectionFormat format)Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.- Parameters:
list- the list to serializeformat- the Swagger collection format- Returns:
- the serialized string
-
deserialize
public <T> T deserialize(java.lang.String value, java.lang.reflect.Type type, SerdeEncoding encoding) throws java.io.IOExceptionDeserializes a string into aTobject.- Type Parameters:
T- the type of the deserialized object- Parameters:
value- the string value to deserializetype- the type to deserializeencoding- the encoding used in the serialized value- Returns:
- the deserialized object
- Throws:
java.io.IOException- exception from reading value to deserializeSerdeParseException- exception from deserialization
-
deserialize
public <T> T deserialize(java.io.InputStream inputStream, java.lang.reflect.Type type, SerdeEncoding encoding) throws java.io.IOExceptionDeserializes a byte[] into aTobject.- Type Parameters:
T- The type of the deserialized object.- Parameters:
inputStream- TheInputStreamcontaining the serialized object data to deserialize.type- The type to deserialize.encoding- The encoding used to serialize value.- Returns:
- The deserialized object, or null if it cannot be deserialized.
- Throws:
java.io.IOException- exception from deserializationSerdeParseException- exception from deserialization
-
deserialize
public <T> T deserialize(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.reflect.Type deserializedHeadersType) throws java.io.IOExceptionDeserialize the provided headers returned from a REST API to an entity instance declared as the model to hold 'Matching' headers. 'Matching' headers are the REST API returned headers those with:- header names same as name of a properties in the entity.
- header names start with value of
HeaderCollectionannotation applied to the properties in the entity.
- Type Parameters:
T- the type of the deserialized object- Parameters:
headers- the REST API returned headersdeserializedHeadersType- the type to deserialize- Returns:
- instance of header entity type created based on provided
headers, if header entity model does not not exists then return null - Throws:
java.io.IOException- If an I/O error occurs
-
-