@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ElectionState that = (ElectionState) o;

        if (epoch != that.epoch) return false;
        if (!leaderId.equals(that.leaderId)) return false;
        if (!votedKey.equals(that.votedKey)) return false;

        return voters.equals(that.voters);
    }
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