title: Java Hashcode and Equals for Java 8 functional interface objects
body: <p>I have some code which looks like the below:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  import java.util.function.Function;
  
  class MyObj {
      private final Double aDouble;
  
      public MyObj(Double aDouble) {
          this.aDouble = aDouble;
      }
  }
  
  class Main {
      public static void main(String[] args) {
          List&lt;Function&lt;MyObj, String&gt;&gt; functionList1 = new ArrayList&lt;&gt;();
          List&lt;Function&lt;MyObj, String&gt;&gt; functionList2 = new ArrayList&lt;&gt;();
  
          // ... Add same Function&lt;MyObj, String&gt;s to both lists
  
          // I want to assert that functionList1.equals functionList2
      }
  }
  </code></pre>
  
  <p>I'd like to check that some <code>Function</code>, <code>Supplier</code>, <code>BiFunction</code> or whatever it might be of <code>MyObj</code>, would be equal to another if the result of calling the <code>Function</code>/<code>Supplier</code> etc returns the same value given the same input. </p>
  
  <p>So in this case, Java would compare the values of the two lists using <code>equals</code> like so <code>functionList1.get(0).apply(standardInstanceOfMyObj)</code> equals <code>functionList2.get(0).apply(standardInstanceOfMyObj)</code> etc.</p>
  
  <p>My question is, how can I override <code>equals</code> and <code>hashcode</code> for a specific type like <code>Function&lt;MyObj, String&gt;</code> to make the above work?</p>