T - class of the entity, representing messagespublic class ParseStringDeserializer<T>
extends java.lang.Object
implements org.apache.kafka.common.serialization.Deserializer<T>
Deserializer for deserialization of entity from
its String representation received from Kafka (a.k.a parsing).| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
KEY_PARSER
Property for the key parser method.
|
static java.lang.String |
VALUE_PARSER
Property for the key parser method.
|
| Constructor and Description |
|---|
ParseStringDeserializer()
Construct an instance with no parser function; a static method name must be
provided in the consumer config
KEY_PARSER or VALUE_PARSER
properties. |
ParseStringDeserializer(java.util.function.BiFunction<java.lang.String,org.apache.kafka.common.header.Headers,T> parser)
Construct an instance with the supplied parser function.
|
ParseStringDeserializer(java.util.function.Function<java.lang.String,T> parser)
Construct an instance with the supplied parser function.
|
| Modifier and Type | Method and Description |
|---|---|
void |
configure(java.util.Map<java.lang.String,?> configs,
boolean isKey) |
T |
deserialize(java.lang.String topic,
byte[] data) |
T |
deserialize(java.lang.String topic,
org.apache.kafka.common.header.Headers headers,
byte[] data) |
java.nio.charset.Charset |
getCharset()
Get the configured charset.
|
java.util.function.BiFunction<java.lang.String,org.apache.kafka.common.header.Headers,T> |
getParser()
Get the configured parser function.
|
void |
setCharset(java.nio.charset.Charset charset)
Set a charset to use when converting byte[] to
String. |
public static final java.lang.String KEY_PARSER
public static final java.lang.String VALUE_PARSER
public ParseStringDeserializer()
KEY_PARSER or VALUE_PARSER
properties.public ParseStringDeserializer(java.util.function.Function<java.lang.String,T> parser)
parser - the function.public ParseStringDeserializer(java.util.function.BiFunction<java.lang.String,org.apache.kafka.common.header.Headers,T> parser)
parser - the function.public void configure(java.util.Map<java.lang.String,?> configs,
boolean isKey)
configure in interface org.apache.kafka.common.serialization.Deserializer<T>public T deserialize(java.lang.String topic, byte[] data)
deserialize in interface org.apache.kafka.common.serialization.Deserializer<T>public T deserialize(java.lang.String topic, org.apache.kafka.common.header.Headers headers, byte[] data)
deserialize in interface org.apache.kafka.common.serialization.Deserializer<T>public void setCharset(java.nio.charset.Charset charset)
String. Default UTF-8.charset - the charset.public java.nio.charset.Charset getCharset()
public java.util.function.BiFunction<java.lang.String,org.apache.kafka.common.header.Headers,T> getParser()