How to get distinct list of object with concat in Java 8
<p>I have 2 Java Classes.</p>

<pre><code>class A {
 String name;
 List&lt;B&gt; numbers;
}

class B {
 Integer number;
}
</code></pre>

<p>I want to get the distinct of Class A and concat the List of B in it.</p>

<p>e.g. Suppose I have a List with the following objects.</p>

<pre><code>List&lt;A&gt;{
 name = "abc"
 List&lt;B&gt;{1,2}

 name= "xyz"
 List&lt;B&gt;{3,4}

 name = "abc"
 List&lt;B&gt;{3,5}
}
</code></pre>

<p>The result should be:</p>

<pre><code>List&lt;A&gt;{
 name = "abc"
 List&lt;B&gt;{1,2,3,5}

 name="xyz"
 List&lt;B&gt;{3,4}
}
</code></pre>

<p>Any help would be appreciated.</p>

<p><strong>Note: I want to achieve this functionality using Java 8 streams.</strong></p>

<p>Thanks</p>