title: Java collection filter comparator
body: <p>I am asked to implement a java library module containing 1 method that is able to filter collections of arbitrary objects using a user-defined filter method and returns the object's identity hash code (unique hash code for the object generated by the JVM), preferably using Java 8 constructs. If multiple objects are found, the largest one should be returned. If the comparator does not sort them uniquely, the largest hash code should be returned. The method should follow the signature you can find below.</p>
  
  <pre><code>public &lt;T&gt; Optional&lt;Integer&gt; getIt(Collection&lt;T&gt; collection, Predicate&lt;T&gt; filter, Comparator&lt;T&gt; comparator)
  </code></pre>
  
  <p>So, I thought to filter first, using:</p>
  
  <pre><code>collection.removeIf(filter.negate());
  </code></pre>
  
  <p>But, what I couldn't get is, how you could get the largest arbitrary object?</p>
  
  <p>Any help is appreciated, thanks</p>