title: Java 8 - chaining constructor call and setter in stream.map()
body: <p>I have a class</p>
  
  <pre><code>class Foo{
      String name;
      // setter, getter
  }
  </code></pre>
  
  <p>which just has a default constructor.</p>
  
  <p>Then, I am trying to create a List of <code>Foo</code> from some string:</p>
  
  <pre><code>Arrays.stream(fooString.split(","))
              .map(name -&gt; {
                  Foo x = new Foo();
                  x.setName(name);
                  return x;
  
              }).collect(Collectors.toList()));
  </code></pre>
  
  <p>Since there is no constructor which takes a name, I can't simply use a method reference. Of course, I could extract those three lines, with the constructor call and the setter, into a method but is there any better or concise way to do that? (without changing <code>Foo</code>, which is a generated file)</p>