K
- key type of serdeV
- value type of serdepublic final class StateSerdes<K,V>
extends java.lang.Object
Constructor and Description |
---|
StateSerdes(java.lang.String topic,
Serde<K> keySerde,
Serde<V> valueSerde)
Create a context for serialization using the specified serializers and deserializers which
must match the key and value types used as parameters for this object; the state changelog topic
is provided to bind this serde factory to, so that future calls for serialize / deserialize do not
need to provide the topic name any more.
|
Modifier and Type | Method and Description |
---|---|
Deserializer<K> |
keyDeserializer()
Return the key deserializer.
|
K |
keyFrom(byte[] rawKey)
Deserialize the key from raw bytes.
|
Serde<K> |
keySerde()
Return the key serde.
|
Serializer<K> |
keySerializer()
Return the key serializer.
|
byte[] |
rawKey(K key)
Serialize the given key.
|
byte[] |
rawValue(V value)
Serialize the given value.
|
java.lang.String |
topic()
Return the topic.
|
Deserializer<V> |
valueDeserializer()
Return the value deserializer.
|
V |
valueFrom(byte[] rawValue)
Deserialize the value from raw bytes.
|
Serde<V> |
valueSerde()
Return the value serde.
|
Serializer<V> |
valueSerializer()
Return the value serializer.
|
static <K,V> StateSerdes<K,V> |
withBuiltinTypes(java.lang.String topic,
java.lang.Class<K> keyClass,
java.lang.Class<V> valueClass)
Create a new instance of
StateSerdes for the given state name and key-/value-type classes. |
public StateSerdes(java.lang.String topic, Serde<K> keySerde, Serde<V> valueSerde)
topic
- the topic namekeySerde
- the serde for keys; cannot be nullvalueSerde
- the serde for values; cannot be nulljava.lang.IllegalArgumentException
- if key or value serde is nullpublic static <K,V> StateSerdes<K,V> withBuiltinTypes(java.lang.String topic, java.lang.Class<K> keyClass, java.lang.Class<V> valueClass)
StateSerdes
for the given state name and key-/value-type classes.K
- the key typeV
- the value typetopic
- the topic namekeyClass
- the class of the key typevalueClass
- the class of the value typeStateSerdes
public Deserializer<K> keyDeserializer()
public Serializer<K> keySerializer()
public Deserializer<V> valueDeserializer()
public Serializer<V> valueSerializer()
public java.lang.String topic()
public K keyFrom(byte[] rawKey)
rawKey
- the key as raw bytespublic V valueFrom(byte[] rawValue)
rawValue
- the value as raw bytespublic byte[] rawKey(K key)
key
- the key to be serializedpublic byte[] rawValue(V value)
value
- the value to be serialized