private boolean isValidVoterKey(Optional<ReplicaKey> voterKey) {
        return voterKey
            .map(key -> {
                if (!OptionalInt.of(key.id()).equals(nodeId)) return false;
                if (!key.directoryId().isPresent()) return true;

                return key.directoryId().get().equals(nodeDirectoryId);
            })
            .orElse(true);
    }
Return true if the voter key matches the local replica's key
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java