title: Constructor as higher-order function
body: <p>I'm facing the problem that I want to map from a Stream 4 elements to the contructor of the record Data:</p>
  <pre class="lang-java prettyprint-override"><code>record Data(String firstname, String middlename, String lastname, String zip) {}
  
  Function4&lt;String, String, String, String, Data&gt; constructor = Data::new;
  List&lt;Data&gt; data = Stream.of(&quot;chris&quot;, &quot;p&quot;, &quot;bacon&quot;, &quot;black&quot;)
                  .map(constructor)
                  .collect(Collectors.toList())
  </code></pre>
  <p>I found a matching higher-order function (<code>Function4</code> from vavr) to describe this constructor with 4 parameter at least. But I cant figure out how to use it in this case.</p>
  <p>Side note: what I try to avoid is building a <code>Collection</code> of 4 elements and have to pass them &quot;manually&quot;.:</p>
  <pre class="lang-java prettyprint-override"><code>    List&lt;Data&gt; datas = rowData.stream()
                  .map(row -&gt; new Data(row.get(0), row.get(1), row.get(2), row.get(3))).toList();
  </code></pre>
  <p>I think this can't be done in Java because at some point in the stream I have to construct a type with parameter arity 4.</p>