public QuorumStateData toQuorumStateData(short version) {
        QuorumStateData data = new QuorumStateData()
            .setLeaderEpoch(epoch)
            .setLeaderId(leaderIdOrSentinel())
            .setVotedId(votedKey.map(ReplicaKey::id).orElse(NOT_VOTED));

        if (version == 0) {
            List<QuorumStateData.Voter> dataVoters = voters
                .stream()
                .map(voterId -> new QuorumStateData.Voter().setVoterId(voterId))
                .collect(Collectors.toList());
            data.setCurrentVoters(dataVoters);
        } else if (version == 1) {
            data.setVotedDirectoryId(
                votedKey.flatMap(ReplicaKey::directoryId).orElse(ReplicaKey.NO_DIRECTORY_ID)
            );
        } else {
            throw new IllegalStateException(
                String.format(
                    "File quorum state store doesn't handle supported version %d", version
                )
            );
        }

        return data;
    }
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