private void updatePrevAssignment(Map<TopicPartition, ConsumerGenerationPair> prevAssignment,
                                          List<TopicPartition> partitions,
                                          String consumer,
                                          int generation) {
            for (TopicPartition partition: partitions) {
                if (prevAssignment.containsKey(partition)) {
                    // only keep the latest previous assignment
                    if (generation > prevAssignment.get(partition).generation) {
                        prevAssignment.put(partition, new ConsumerGenerationPair(consumer, generation));
                    }
                } else {
                    prevAssignment.put(partition, new ConsumerGenerationPair(consumer, generation));
                }
            }
        }
update the prevAssignment with the partitions, consumer and generation in parameters

@param partitions:       The partitions to be updated the prevAssignment
@param consumer:         The consumer Id
@param prevAssignment:   The assignment contains the assignment with the 2nd largest generation
@param generation:       The generation of this assignment (partitions)
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java