private static Map<TopicPartition, OffsetAndMetadata> validate(final Map<TopicPartition, OffsetAndMetadata> offsets) {
        for (OffsetAndMetadata offsetAndMetadata : offsets.values()) {
            if (offsetAndMetadata.offset() < 0) {
                throw new IllegalArgumentException("Invalid offset: " + offsetAndMetadata.offset());
            }
        }

        return Collections.unmodifiableMap(offsets);
    }
Validates the offsets are not negative and then returns the given offset map as
{@link Collections#unmodifiableMap(Map) as unmodifiable}.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/CommitEvent.java