title: Require some inputs to make piece of code better with Java-8
body: <p>I have small piece of code (POJO) with java-8. My question is can I do something better with using java-8? I have mentioned some comments in class. </p>
  
  <p>Assume that I have <code>Person</code>, <code>Standard</code> and <code>Subject</code> pojos and also do not worry about <code>equals</code> and <code>hashCode</code> methods, I just want inputs with respect to <code>Java-8</code>.</p>
  
  <pre><code>package com.java8.learn.domain;
  
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Map;
  import java.util.Set;
  
  /**
   * @author Vishal.Zanzrukia
   *
   */
  public class Teacher extends Person {
  
      private Map&lt;Standard, Set&lt;Subject&gt;&gt; standardWiseSubjects;
  
      public Map&lt;Standard, Set&lt;Subject&gt;&gt; getStandardWiseSubjects() {
          return standardWiseSubjects;
      }
  
      public void addStandardWiseSubject(Subject subject, Standard standard) {
          if (this.standardWiseSubjects == null) {
              this.standardWiseSubjects = new HashMap&lt;&gt;();
          }
          if (this.standardWiseSubjects.containsKey(standard)) {
              this.standardWiseSubjects.get(standard).add(subject);
          } else {
              Set&lt;Subject&gt; subjects = new HashSet&lt;&gt;();
              subjects.add(subject);
              this.standardWiseSubjects.put(standard, subjects);
          }
      }
  
      // I need some inputs over here.
      public Map&lt;Subject, Set&lt;Standard&gt;&gt; getSubjectWiseStandards() {
  
          if (this.standardWiseSubjects == null) {
              return null;
          }
  
          Map&lt;Subject, Set&lt;Standard&gt;&gt; output = new HashMap&lt;&gt;();
  
          this.standardWiseSubjects.values().parallelStream().flatMap(set -&gt; set.stream()).forEach(subject -&gt; {
              Set&lt;Standard&gt; standards = new HashSet&lt;&gt;();
              this.standardWiseSubjects.forEach((standard, subjects) -&gt; {
                  // TODO can I convert this if condition into predicate?
                  if (subjects.contains(subject)) {
                      standards.add(standard);
                  }
              });
              output.put(subject, standards);
          });
  
          return output;
      }
  }
  </code></pre>