class VoteProposer {

  public Optional<ValidatorVote> getVote(final Address localAddress, final VoteTally tally) {
    final Collection<Address> validators = tally.getValidators();
    final List<Map.Entry<Address, VoteType>> validVotes = new ArrayList<>();

    proposals
        .entrySet()
        .forEach(
            proposal -> {
              if (voteNotYetCast(
                  localAddress, proposal.getKey(), proposal.getValue(), validators, tally)) {
                validVotes.add(proposal);
              }
            });

    if (validVotes.isEmpty()) {
      return Optional.empty();
    }

    // Get the next position in the voting queue we should propose
    final int currentVotePosition = votePosition.updateAndGet(i -> ++i % validVotes.size());

    final Map.Entry<Address, VoteType> voteToCast = validVotes.get(currentVotePosition);

    // Get a vote from the valid votes and return it
    return Optional.of(new ValidatorVote(voteToCast.getValue(), localAddress, voteToCast.getKey()));
  }

}