SerializerAdapter<T> Interface

Type Parameters

T

the original serializer

public interface SerializerAdapter<T>

This interface defines the behaviors an adapter of a serializer needs to implement.

Method Summary

Modifier and Type Method and Description
abstract U <U>deserialize(String value, Type type)

Deserializes a string into a U object using the current T.

abstract retrofit2.Converter.Factory converterFactory()
abstract java.lang.String serialize(Object object)

Serializes an object into a JSON string.

abstract java.lang.String serializeList(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.

abstract java.lang.String serializeRaw(Object object)

Serializes an object into a raw string.

abstract T serializer()

Method Details

<U>deserialize

public abstract U deserialize(String value, Type type)

Deserializes a string into a U object using the current T.

Parameters:

value - the string value to deserialize.
type - the type to deserialize.

Returns:

the deserialized object.

Throws:

java.io.IOException - exception in deserialization

converterFactory

public abstract Converter.Factory converterFactory()

Returns:

a converter factory for Retrofit

serialize

public abstract String serialize(Object object)

Serializes an object into a JSON string.

Parameters:

object - the object to serialize.

Returns:

the serialized string. Null if the object to serialize is null.

Throws:

java.io.IOException - exception from serialization.

serializeList

public abstract String serializeList(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.

Parameters:

list - the list to serialize.
format - the Swagger collection format.

Returns:

the serialized string

serializeRaw

public abstract String serializeRaw(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.

serializer

public abstract T serializer()

Returns:

the adapted original serializer

Applies to