@IgnoreJRERequirement public final class OptionalConverterFactory extends Converter.Factory
Converter.Factory
which supports Java's Optional
to wrap null values from
another converter.
This factory is installed by default on the JVM and Android API 24+. If you are using another converter which tries to serialize all types, such as Moshi or Gson, the default installation of this factory never gets a chance to run. To work around this, you can explicitly install this factory before your serialization library converter.
Modifier and Type | Method and Description |
---|---|
static OptionalConverterFactory |
create() |
Converter<okhttp3.ResponseBody,?> |
responseBodyConverter(java.lang.reflect.Type type,
java.lang.annotation.Annotation[] annotations,
Retrofit retrofit)
Returns a
Converter for converting an HTTP response body to type , or null if
type cannot be handled by this factory. |
getParameterUpperBound, getRawType, requestBodyConverter, stringConverter
public static OptionalConverterFactory create()
@Nullable public Converter<okhttp3.ResponseBody,?> responseBodyConverter(java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, Retrofit retrofit)
Converter.Factory
Converter
for converting an HTTP response body to type
, or null if
type
cannot be handled by this factory. This is used to create converters for
response types such as SimpleResponse
from a Call<SimpleResponse>
declaration.responseBodyConverter
in class Converter.Factory