Class Record<K,V>
- java.lang.Object
-
- io.smallrye.reactive.messaging.kafka.Record<K,V>
-
- Type Parameters:
K
- the type of the keyV
- the type of the value
public class Record<K,V> extends Object
Represents a produced Kafka record, so a pair {key, value}.This class is used by application willing to configure the written record. The couple key/value is used for, respectively, the record's key and record's value. Instances are used as message's payload.
Both key and value can be
null
. Instances of this class are immutable.If the application needs to configure more aspect of the record, use the
OutgoingCloudEventMetadata
.If the attached metadata configures the key, the key provided by the record is overidden.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description K
key()
static <K,V>
Record<K,V>of(K key, V value)
Creates a new record.V
value()
<T> Record<T,V>
withKey(T key)
Creates a new instance ofRecord
with given key and the value from the current record.<T> Record<K,T>
withValue(T value)
Creates a new instance ofRecord
with the key from the current record and the new value.
-
-
-
Method Detail
-
of
public static <K,V> Record<K,V> of(K key, V value)
Creates a new record.- Type Parameters:
K
- the type of the keyV
- the type of the value- Parameters:
key
- the key, can benull
value
- the value, can benull
-
key
public K key()
- Returns:
- the key, may be
null
-
value
public V value()
- Returns:
- the value, may be
null
-
withKey
public <T> Record<T,V> withKey(T key)
Creates a new instance ofRecord
with given key and the value from the current record.- Type Parameters:
T
- the type of the new key- Parameters:
key
- the new key, can benull
- Returns:
- the new record
-
-