public boolean isVoter(ReplicaKey replicaKey) {
            if (voterKey.id() != replicaKey.id()) return false;

            if (voterKey.directoryId().isPresent()) {
                return voterKey.directoryId().equals(replicaKey.directoryId());
            } else {
                // configured voter set doesn't include a directory id so it is a voter as long as
                // the ids match
                return true;
            }
        }
Returns if the provided replica key matches this voter node.

If the voter node includes the directory id, the {@code replicaKey} directory id must
match the directory id specified by the voter set.

If the voter node doesn't include the directory id ({@code Optional.empty()}), a replica
is the voter as long as the node id matches. The directory id is not checked.

@param replicaKey the replica key
@return true if the replica key is the voter, otherwise false
raft/src/main/java/org/apache/kafka/raft/internals/VoterSet.java