public final class HttpSerializationProviders
extends java.lang.Object
HttpSerializationProvider
s.Modifier and Type | Method and Description |
---|---|
static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
formUrlEncodedDeserializer()
Creates an
HttpDeserializer that can deserialize key-values Map s
with StandardCharsets.UTF_8 from urlencoded forms. |
static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
formUrlEncodedDeserializer(java.nio.charset.Charset charset)
Creates an
HttpDeserializer that can deserialize key-values Map s
with StandardCharsets.UTF_8 from urlencoded forms. |
static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
formUrlEncodedDeserializer(java.nio.charset.Charset charset,
java.util.function.Predicate<HttpHeaders> checkContentType)
Creates an
HttpDeserializer that can deserialize key-values Map s
with StandardCharsets.UTF_8 from urlencoded forms. |
static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
formUrlEncodedSerializer()
Creates an
HttpSerializer that can serialize a key-values Map s
with StandardCharsets.UTF_8 Charset to urlencoded forms. |
static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
formUrlEncodedSerializer(java.nio.charset.Charset charset)
Creates an
HttpSerializer that can serialize key-values Map s with the specified Charset
to to urlencoded forms. |
static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
formUrlEncodedSerializer(java.nio.charset.Charset charset,
java.util.function.Consumer<HttpHeaders> addContentType)
Creates an
HttpSerializer that can serialize a key-values Map s 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,
java.util.function.Consumer<HttpHeaders> addContentType,
java.util.function.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,
java.util.function.Consumer<HttpHeaders> addContentType,
java.util.function.Predicate<HttpHeaders> checkContentType)
Creates a new
HttpSerializationProvider that could serialize/deserialize to/from the desired content-type
using the passed Serializer . |
static HttpDeserializer<java.lang.String> |
textDeserializer()
|
static HttpDeserializer<java.lang.String> |
textDeserializer(java.nio.charset.Charset charset)
|
static HttpDeserializer<java.lang.String> |
textDeserializer(java.nio.charset.Charset charset,
java.util.function.Predicate<HttpHeaders> checkContentType)
|
static HttpSerializer<java.lang.String> |
textSerializer()
|
static HttpSerializer<java.lang.String> |
textSerializer(java.nio.charset.Charset charset)
|
static HttpSerializer<java.lang.String> |
textSerializer(java.nio.charset.Charset charset,
java.util.function.Consumer<HttpHeaders> addContentType)
|
public static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedSerializer()
HttpSerializer
that can serialize a key-values Map
s
with StandardCharsets.UTF_8
Charset
to urlencoded forms.HttpSerializer
that could serialize key-value Map
.public static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedSerializer(java.nio.charset.Charset charset)
HttpSerializer
that can serialize key-values Map
s 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<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedSerializer(java.nio.charset.Charset charset, java.util.function.Consumer<HttpHeaders> addContentType)
HttpSerializer
that can serialize a key-values Map
s 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<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedDeserializer()
HttpDeserializer
that can deserialize key-values Map
s
with StandardCharsets.UTF_8
from urlencoded forms.HttpDeserializer
that could deserialize a key-values Map
.public static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedDeserializer(java.nio.charset.Charset charset)
HttpDeserializer
that can deserialize key-values Map
s
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 SerializationException
HttpDeserializer
that could deserialize a key-value Map
.public static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedDeserializer(java.nio.charset.Charset charset, java.util.function.Predicate<HttpHeaders> checkContentType)
HttpDeserializer
that can deserialize key-values Map
s
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 SerializationException
HttpDeserializer
that could deserialize a key-value Map
.public static HttpSerializer<java.lang.String> textSerializer()
HttpSerializer
that could serialize String
.public static HttpSerializer<java.lang.String> textSerializer(java.nio.charset.Charset charset)
charset
- Charset
for the String
that will be serialized.HttpSerializer
that could serialize from String
.public static HttpSerializer<java.lang.String> textSerializer(java.nio.charset.Charset charset, java.util.function.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<java.lang.String> textDeserializer()
HttpDeserializer
that could deserialize String
.public static HttpDeserializer<java.lang.String> textDeserializer(java.nio.charset.Charset charset)
charset
- Charset
for the String
that will be deserialized.HttpDeserializer
that could deserialize String
.public static HttpDeserializer<java.lang.String> textDeserializer(java.nio.charset.Charset charset, java.util.function.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 SerializationException
HttpDeserializer
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, java.util.function.Consumer<HttpHeaders> addContentType, java.util.function.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 SerializationException
HttpSerializationProvider
that has the capability of serializing/deserializing to/from a desired
content-type.public static HttpSerializationProvider serializationProvider(SerializationProvider serializationProvider, java.util.function.Consumer<HttpHeaders> addContentType, java.util.function.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.