title: How return lambda to thenComparing method
body: <p>I have a code that I need to modify.
  It looks like that:</p>
  
  <pre><code>new ComparatorFactory&lt;&gt;(thing -&gt; thing.getLong());
  return new ComparatorFactory.bySmthThenLong(things);
  </code></pre>
  
  <p>And the factory class itself:</p>
  
  <pre><code>private final Function&lt;T, Long&gt; getLong;
   ComparatorFactory(Function&lt;T, Long&gt; getLong) {
    this.getLong = getLong;
  }
  
  Comparator&lt;T&gt; bySmth(Collection&lt;T&gt; things) {
    // Smth happens, then returns comparator. 
  }
  </code></pre>
  
  <p>And then I need to chain the <code>bySmth</code> method to another method, and these two methods should be separate as sometimes just the first stage is used. 
  I need to do something to this <code>Long</code> before next round of comparing, so I have a method:</p>
  
  <pre><code>private Function&lt;T, Long&gt; preprocessLong(Function&lt;T, Long&gt; getLong) {
   // divide Long by some number and return new function.
  }
  </code></pre>
  
  <p>So the creation of this comparator would look like that to my understanding:</p>
  
  <pre><code>Comparator&lt;T&gt; bySmthThenLong(Collection&lt;T&gt; things) {
    return bySmth(things).thenComparing(preprocessLong(getLong));
  }
  </code></pre>
  
  <p>But I don't understand what the <code>preprocessLong</code> method should look like inside. Could you help? Thanks.</p>