public boolean isLeader(int nodeId) {
        if (nodeId < 0)
            throw new IllegalArgumentException("Invalid negative nodeId: " + nodeId);
        return leaderIdOrSentinel() == nodeId;
    }
Encapsulate election state stored on disk after every state change.
raft/src/main/java/org/apache/kafka/raft/ElectionState.java