public static ElectionState fromQuorumStateData(QuorumStateData data) {
        Optional<ReplicaKey> votedKey = data.votedId() == NOT_VOTED ?
            Optional.empty() :
            Optional.of(ReplicaKey.of(data.votedId(), data.votedDirectoryId()));

        return new ElectionState(
            data.leaderEpoch(),
            data.leaderId() == UNKNOWN_LEADER_ID ? OptionalInt.empty() : OptionalInt.of(data.leaderId()),
            votedKey,
            data.currentVoters().stream().map(QuorumStateData.Voter::voterId).collect(Collectors.toSet())
        );
    }
Return if the replica has voted for the given candidate.

A replica has voted for a candidate if all of the following are true:
1. the node's id and voted id match and
2. if the voted directory id is set, it matches the node's directory id

@param nodeKey the id and directory id of the replica
@return true when the arguments match, otherwise false
raft/src/main/java/org/apache/kafka/raft/ElectionState.java