public <NewK> Record<NewK, V> withKey(final NewK key) {
        return new Record<>(key, value, timestamp, headers);
    }
A convenient way to produce a new record if you only need to change the key.

Copies the attributes of this record with the key replaced.

@param key The key of the result record. May be null.
@param <NewK> The type of the new record's key.
@return A new Record instance with all the same attributes (except that the key is replaced).
streams/src/main/java/org/apache/kafka/streams/processor/api/Record.java