title: Pass Java 8 streaming map function as a parameter
body: <p>I have a string which is comma separated an I want to convert it to an array. However in some cases, I require integer parsing, sometimes double.
  Is there a way I can pass mapToDouble or mapToInt rather than writing the entire thing again.</p>
  
  <pre><code>return Arrays.stream(test.split(",")).mapToDouble(x -&gt; {
          if (StringUtils.isEmpty(x)) {
              return condition ? -1 : 0;
          }
          return Double.parseDouble(x);
  }).toArray();
  
  return Arrays.stream(test.split(",")).mapToInt(x -&gt; {
          if (StringUtils.isEmpty(x)) {
              return condition ? -1 : 0;
          }
          return Integer.parseInt(x);
  }).toArray();
  </code></pre>
  
  <p>Is there a way to make this into a function, where I can have a generic function and make store the appropriate array?</p>