Intersection of two collections of different objects types java 8
<p>I have two lists of objects:</p>

<pre><code>List&lt;SampleClassOne&gt; listOne;
List&lt;SampleClassTwo&gt; listTwo;
</code></pre>

<p>SampleClassOne:</p>

<pre><code>public class SampleClassOne{
  private String myFirstProperty;
  //ommiting getters-setters
}
</code></pre>

<p>SampleClassTwo:</p>

<pre><code>public class SampleClassTwo{
  private String myOtherProperty;
  //ommiting getters-setters
}
</code></pre>

<p>RootSampleClass:</p>

<pre><code>public class RootSampleClass{
  private SampleClassOne classOne;
  private SampleClassTwo classTwo;
  //ommiting getters-setters
}
</code></pre>

<p>Now I would like to merge two lists into new list of type RootSampleClass based on condition:</p>

<pre><code>if(classOneObject.getMyFirstProperty().equals(classTwoObject.getMyOtherProperty()){
 //create new RootSampleClass based on classOneObject and classTwoObject and add it to another collection
}
</code></pre>

<p>Pseudo code:</p>

<pre><code>foreach(one: collectionOne){
 foreach(two: collectionTwo){
    if(one.getMyFirstProperty().equals(two.getMyOtherProperty()){
    collectionThree.add(new RootSampleClass(one, two));
    }
 }
}
</code></pre>

<p>I am interested in java 8. I would like to have the best performance here that's why I am asking for existing solution without writing custom foreach.</p>