docs: private void changeRole(PrimaryTerm term) {
      threadContext.execute(() -> {
        if (term.term() >= currentTerm) {
          log.debug("{} - Term changed: {}", memberId, term);
          currentTerm = term.term();
          leader = term.primary() != null ? term.primary().memberId() : null;
          followers = term.backups(replicationFactor - 1)
              .stream()
              .map(GroupMember::memberId)
              .collect(Collectors.toList());
  
          if (Objects.equals(leader, clusterMembershipService.getLocalMember().id())) {
            if (this.role == null) {
              this.role = new LeaderRole(this);
              log.debug("{} transitioning to {}", clusterMembershipService.getLocalMember().id(), Role.LEADER);
            } else if (this.role.role() != Role.LEADER) {
              this.role.close();
              this.role = new LeaderRole(this);
              log.debug("{} transitioning to {}", clusterMembershipService.getLocalMember().id(), Role.LEADER);
            }
          } else if (followers.contains(clusterMembershipService.getLocalMember().id())) {
            if (this.role == null) {
              this.role = new FollowerRole(this);
              log.debug("{} transitioning to {}", clusterMembershipService.getLocalMember().id(), Role.FOLLOWER);
            } else if (this.role.role() != Role.FOLLOWER) {
              this.role.close();
              this.role = new FollowerRole(this);
              log.debug("{} transitioning to {}", clusterMembershipService.getLocalMember().id(), Role.FOLLOWER);
            }
          } else {
            if (this.role == null) {
              this.role = new NoneRole(this);
              log.debug("{} transitioning to {}", clusterMembershipService.getLocalMember().id(), Role.NONE);
            } else if (this.role.role() != Role.NONE) {
              this.role.close();
              this.role = new NoneRole(this);
              log.debug("{} transitioning to {}", clusterMembershipService.getLocalMember().id(), Role.NONE);
            }
          }
        }
      });
    }