title: Java Stream map to multiple attribute
body: <p>I'm using <code>Optional&lt;ObjectNode&gt;</code> and extracting various attributes out of it using streams.</p>
  
  <pre><code>class MyCompany {
      private Age age;
      private Name name;
  
      // getters and setters
  
  }
  
          myJSON
                  .map(jsonObj -&gt; getAge(jsonObj, "age"))
                  .map(age -&gt; new Age(age))
                  .ifPresent(myCompany::setAge);
  
  
          myJSON
                  .map(jsonObj -&gt; getName(jsonObj, "name"))
                  .map(name -&gt; new Name(name))
                  .ifPresent(myCompany::setName);
  
  public Integer getAge(ObjectNode jsonObj, String toGet) {
      Integer value = null;
  
      if (jsonObj(toGet)) {
  
          value = jsonObj(toGet).intValue();
  
      }
  
      return value;
  }
  </code></pre>
  
  <p>Now I want to change the <code>MyCompany</code> to include a new <code>Person</code> class instead and <code>Person</code> shall include the name and age attributes. How can I use the Java stream in a single statement to formulate <code>Person</code> from the name and age and then set it in <code>MyCompany</code></p>
  
  <pre><code>class Person {
      private Age age;
      private Name name;
      // getters and setters
  
  
      public void Person(Age age, Name name) {
         this.name = name;
         this.age = age;
  
      }
  }
  
  class MyCompany {
      private Person person;
      //getters and setters for Person
  }
  </code></pre>