title: Grouping By in java 8 Stream API
body: <p>I am new to java Stream API and have a use case to solve using it.</p>
  
  <pre><code>Map&lt;Object, ? extends Object&gt; map = list.stream().collect(Collectors.groupingBy(p-&gt;p.getX()
                                                              ,Collectors.groupingBy(p-&gt;p.getY()
                                                              ,Collectors.groupingBy(p-&gt;p.getZ()))));
  </code></pre>
  
  <p>Consider that x,y and z are the attributes of a given class. This works fine if we have the order of grouping (which attribute to consider first, second and so on...) predefined. </p>
  
  <p>(In given piece of code attribute x is considered 1st, y 2nd and z 3rd). </p>
  
  <p>Now, In my case, order of grouping is not predefined and may change at run time. So, at compile time i don't know what to pass in collect method.
  I am looking for a solution by which I can read the config string and change grouping at run time.</p>