private void addBatchMetadata(BatchMetadata batch) {
        if (batchMetadata.size() == ProducerStateEntry.NUM_BATCHES_TO_RETAIN) batchMetadata.removeFirst();
        batchMetadata.add(batch);
    }
Returns a new instance with the provided parameters (when present) and the values from the current instance
otherwise.
storage/src/main/java/org/apache/kafka/storage/internals/log/ProducerStateEntry.java