public OptionalInt leaderEpochFor(TopicPartition tp) {
        PartitionMetadata partitionMetadata = metadataByPartition.get(tp);
        if (partitionMetadata == null || !partitionMetadata.leaderEpoch.isPresent()) {
            return OptionalInt.empty();
        } else {
            return OptionalInt.of(partitionMetadata.leaderEpoch.get());
        }
    }
Get leader-epoch for partition.

@param tp partition
@return leader-epoch if known, else return OptionalInt.empty()
clients/src/main/java/org/apache/kafka/clients/MetadataSnapshot.java