public static <T> Batch<T> data(
        long baseOffset,
        int epoch,
        long appendTimestamp,
        int sizeInBytes,
        List<T> records
    ) {
        if (records.isEmpty()) {
            throw new IllegalArgumentException(
                String.format(
                    "Batch must contain at least one record; baseOffset = %d; epoch = %d",
                    baseOffset,
                    epoch
                )
            );
        }

        return new Batch<>(
            baseOffset,
            epoch,
            appendTimestamp,
            sizeInBytes,
            baseOffset + records.size() - 1,
            records,
            Collections.emptyList()
        );
    }
Create a data batch with the given base offset, epoch and records.

@param baseOffset offset of the first record in the batch
@param epoch epoch of the leader that created this batch
@param appendTimestamp timestamp in milliseconds of when the batch was appended
@param sizeInBytes number of bytes used by this batch
@param records the list of records in this batch
raft/src/main/java/org/apache/kafka/raft/Batch.java