public final class HttpSerializationProviders
extends Object
HttpSerializationProviders.| Modifier and Type | Method and Description |
|---|---|
static HttpDeserializer<Map<String,List<String>>> |
formUrlEncodedDeserializer()
Creates an
HttpDeserializer that can deserialize key-values Maps
with StandardCharsets.UTF_8 from urlencoded forms. |
static HttpDeserializer<Map<String,List<String>>> |
formUrlEncodedDeserializer(Charset charset)
Creates an
HttpDeserializer that can deserialize key-values Maps
with StandardCharsets.UTF_8 from urlencoded forms. |
static HttpDeserializer<Map<String,List<String>>> |
formUrlEncodedDeserializer(Charset charset,
Predicate<HttpHeaders> checkContentType)
Creates an
HttpDeserializer that can deserialize key-values Maps
with StandardCharsets.UTF_8 from urlencoded forms. |
static HttpSerializer<Map<String,List<String>>> |
formUrlEncodedSerializer()
Creates an
HttpSerializer that can serialize a key-values Maps
with StandardCharsets.UTF_8 Charset to urlencoded forms. |
static HttpSerializer<Map<String,List<String>>> |
formUrlEncodedSerializer(Charset charset)
Creates an
HttpSerializer that can serialize key-values Maps with the specified Charset
to to urlencoded forms. |
static HttpSerializer<Map<String,List<String>>> |
formUrlEncodedSerializer(Charset charset,
Consumer<HttpHeaders> addContentType)
Creates an
HttpSerializer that can serialize a key-values Maps with the specified Charset
to urlencoded forms. |
static HttpSerializationProvider |
jsonSerializer(SerializationProvider serializationProvider)
Creates a new
HttpSerializationProvider that could serialize/deserialize to/from JSON using the passed
SerializationProvider. |
static HttpSerializationProvider |
jsonSerializer(Serializer serializer)
Creates a new
HttpSerializationProvider that could serialize/deserialize to/from JSON using the passed
Serializer. |
static HttpSerializationProvider |
serializationProvider(SerializationProvider serializationProvider,
Consumer<HttpHeaders> addContentType,
Predicate<HttpHeaders> checkContentType)
Creates a new
HttpSerializationProvider that could serialize/deserialize to/from the desired content-type
using the passed SerializationProvider. |
static HttpSerializationProvider |
serializationProvider(Serializer serializer,
Consumer<HttpHeaders> addContentType,
Predicate<HttpHeaders> checkContentType)
Creates a new
HttpSerializationProvider that could serialize/deserialize to/from the desired content-type
using the passed Serializer. |
static HttpDeserializer<String> |
textDeserializer()
|
static HttpDeserializer<String> |
textDeserializer(Charset charset)
|
static HttpDeserializer<String> |
textDeserializer(Charset charset,
Predicate<HttpHeaders> checkContentType)
|
static HttpSerializer<String> |
textSerializer()
|
static HttpSerializer<String> |
textSerializer(Charset charset)
|
static HttpSerializer<String> |
textSerializer(Charset charset,
Consumer<HttpHeaders> addContentType)
|
public static HttpSerializer<Map<String,List<String>>> formUrlEncodedSerializer()
HttpSerializer that can serialize a key-values Maps
with StandardCharsets.UTF_8 Charset to urlencoded forms.HttpSerializer that could serialize key-value Map.public static HttpSerializer<Map<String,List<String>>> formUrlEncodedSerializer(Charset charset)
HttpSerializer that can serialize key-values Maps with the specified Charset
to to urlencoded forms.charset - Charset for the key-value Map that will be serialized.HttpSerializer that could serialize from key-value Map.public static HttpSerializer<Map<String,List<String>>> formUrlEncodedSerializer(Charset charset, Consumer<HttpHeaders> addContentType)
HttpSerializer that can serialize a key-values Maps with the specified Charset
to urlencoded forms.charset - Charset for the key-value Map that will be serialized.addContentType - A Consumer that adds relevant headers to the passed HttpHeaders matching
the serialized payload. Typically, this involves adding a HttpHeaderNames.CONTENT_TYPE header.HttpSerializer that could serialize from key-value Map.public static HttpDeserializer<Map<String,List<String>>> formUrlEncodedDeserializer()
HttpDeserializer that can deserialize key-values Maps
with StandardCharsets.UTF_8 from urlencoded forms.HttpDeserializer that could deserialize a key-values Map.public static HttpDeserializer<Map<String,List<String>>> formUrlEncodedDeserializer(Charset charset)
HttpDeserializer that can deserialize key-values Maps
with StandardCharsets.UTF_8 from urlencoded forms.charset - Charset for the key-value Map that will be deserialized.
deserialized payload. If the validation fails, then deserialization will fail with SerializationExceptionHttpDeserializer that could deserialize a key-value Map.public static HttpDeserializer<Map<String,List<String>>> formUrlEncodedDeserializer(Charset charset, Predicate<HttpHeaders> checkContentType)
HttpDeserializer that can deserialize key-values Maps
with StandardCharsets.UTF_8 from urlencoded forms.charset - Charset for the key-value Map that will be deserialized.checkContentType - Checks the HttpHeaders to see if a compatible encoding is found.
deserialized payload. If the validation fails, then deserialization will fail with SerializationExceptionHttpDeserializer that could deserialize a key-value Map.public static HttpSerializer<String> textSerializer()
HttpSerializer that could serialize String.public static HttpSerializer<String> textSerializer(Charset charset)
charset - Charset for the String that will be serialized.HttpSerializer that could serialize from String.public static HttpSerializer<String> textSerializer(Charset charset, Consumer<HttpHeaders> addContentType)
charset - Charset for the String that will be serialized.addContentType - A Consumer that adds relevant headers to the passed HttpHeaders matching
the serialized payload. Typically, this involves adding a HttpHeaderNames.CONTENT_TYPE header.HttpSerializer that could serialize from String.public static HttpDeserializer<String> textDeserializer()
HttpDeserializer that could deserialize String.public static HttpDeserializer<String> textDeserializer(Charset charset)
charset - Charset for the String that will be deserialized.HttpDeserializer that could deserialize String.public static HttpDeserializer<String> textDeserializer(Charset charset, Predicate<HttpHeaders> checkContentType)
charset - Charset for the String that will be deserialized.checkContentType - A Predicate that validates the passed HttpHeaders as expected for the
deserialized payload. If the validation fails, then deserialization will fail with SerializationExceptionHttpDeserializer that could deserialize String.public static HttpSerializationProvider jsonSerializer(Serializer serializer)
HttpSerializationProvider that could serialize/deserialize to/from JSON using the passed
Serializer. For serialization, the returned HttpSerializationProvider adds a
HttpHeaderNames.CONTENT_TYPE header with value HttpHeaderValues.APPLICATION_JSON.
For deserialization, it expects a HttpHeaderNames.CONTENT_TYPE header with value
HttpHeaderValues.APPLICATION_JSON. If the expected header is not present, then deserialization will fail
with SerializationException.serializer - Serializer that has the capability of serializing/deserializing to/from JSON.HttpSerializationProvider that has the capability of serializing/deserializing to/from JSON.public static HttpSerializationProvider jsonSerializer(SerializationProvider serializationProvider)
HttpSerializationProvider that could serialize/deserialize to/from JSON using the passed
SerializationProvider. For serialization, the returned HttpSerializationProvider adds a
HttpHeaderNames.CONTENT_TYPE header with value HttpHeaderValues.APPLICATION_JSON.
For deserialization, it expects a HttpHeaderNames.CONTENT_TYPE header with value
HttpHeaderValues.APPLICATION_JSON. If the expected header is not present, then deserialization will fail
with SerializationException.serializationProvider - SerializationProvider that has the capability of serializing/deserializing
to/from JSON.HttpSerializationProvider that has the capability of serializing/deserializing to/from JSON.public static HttpSerializationProvider serializationProvider(Serializer serializer, Consumer<HttpHeaders> addContentType, Predicate<HttpHeaders> checkContentType)
HttpSerializationProvider that could serialize/deserialize to/from the desired content-type
using the passed Serializer.
For serialization, the returned HttpSerializationProvider
would update HttpHeaders appropriately to indicate the content-type using the passed
addContentType.
For deserialization, it would validate headers as specified by the passed
checkContentType predicate. If the validation fails, then deserialization will fail with
SerializationException.
serializer - Serializer that has the capability of serializing/deserializing to/from a desired
content-type.addContentType - A Consumer that adds relevant headers to the passed HttpHeaders matching
the serialized payload. Typically, this involves adding a HttpHeaderNames.CONTENT_TYPE header.checkContentType - A Predicate that validates the passed HttpHeaders as expected for the
deserialized payload. If the validation fails, then deserialization will fail with SerializationExceptionHttpSerializationProvider that has the capability of serializing/deserializing to/from a desired
content-type.public static HttpSerializationProvider serializationProvider(SerializationProvider serializationProvider, Consumer<HttpHeaders> addContentType, Predicate<HttpHeaders> checkContentType)
HttpSerializationProvider that could serialize/deserialize to/from the desired content-type
using the passed SerializationProvider.
For serialization, the returned HttpSerializationProvider
would update HttpHeaders appropriately to indicate the content-type using the passed
addContentType.
For deserialization, it would validate headers as specified by the passed
checkContentType predicate. If the validation fails, then deserialization will fail with
SerializationException.
serializationProvider - SerializationProvider that has the capability of serializing/deserializing
to/from a desired content-type.addContentType - A Consumer that adds relevant headers to the passed HttpHeaders matching
the serialized payload. Typically, this involves adding a HttpHeaderNames.CONTENT_TYPE header.checkContentType - A Predicate that validates the passed HttpHeaders as expected for the
deserialized payload. If the validation fails, then deserialization will fail with
SerializationException.HttpSerializationProvider that has the capability of serializing/deserializing to/from a desired
content-type.