title: How to call entrySet method on Mono<Map<Entity, Integer>>
body: <p>Let's say that I have a method <strong>findAll</strong> which is returning <code>Flux&lt;Song&gt;</code> from <code>ReactiveMongoRepository&lt;Song, String&gt;</code>.</p>
  
  <p>Below I have traditional java stream approach to find the x top-voted songs which is suggested by @Naman:</p>
  
  <pre><code>return songRepository.findAll()
      .collect(Collectors.toMap(Function.identity(), this::getSumOfVotes))
      .entrySet().stream() --entrySet method is not recognized by IntelliJ
      .sorted(Map.Entry.&lt;Song,Integer&gt;comparingByValue().reversed())
      .limit(numberOfTopSongs)
      .collect(Collectors.toMap(e -&gt; e.getKey().getId(), Map.Entry::getValue, (a, b) -&gt; a, LinkedHashMap::new));
  </code></pre>
  
  <p>Above solution works for <code>Iterable</code>, <code>Set</code> and <code>List</code> but the problem occurs when I pretend to call method <code>entrySet</code> on <code>Mono&lt;Map&lt;Song, Integer&gt;&gt;</code>. That's my first dive deep into <code>Web Flux</code> and that's why I am a little bit confused why method <code>entrySet</code> is not available for <code>Mono</code> type.</p>
  
  <p>I have found a piece of code like: </p>
  
  <pre><code>Mono&lt;Map&lt;ByteBuffer, ByteBuffer&gt;&gt; serializedMap = Flux.fromIterable(() -&gt; map.entrySet().iterator())
          .collectMap(entry -&gt; rawKey(entry.getKey()), entry -&gt; rawValue(entry.getValue()));
  </code></pre>
  
  <p>but I try to avoid repacking my:</p>
  
  <pre><code>songRepository.findAll()
          .collect(Collectors.toMap(Function.identity(), this::getSumOfVotes))
  </code></pre>
  
  <p>to <code>Flux.fromIterable</code> again.</p>
  
  <p>I will be grateful for suggestions on what I am doing wrong or tips on how to skip this obstacle.</p>