title: Collecting elements of a stream in Java 8 and reducing some of those elements into a single element in the resulting collection
body: <p>The following stream operation results in a <code>Stream&lt;DateCount&gt;</code> where each element represents a sequence of dates with associated counts.  If I have elements from Monday to Sunday and I want to summarize Friday, Saturday or Sunday into a single new <code>DateCount</code> element, how would I achieve that?  Ultimately, my resulting stream should only contain elements for Monday to Friday, but the count for Friday should be a sum of the counts from Friday, Saturday and Sunday.  I think I need to create a <code>Collector</code> for this, but I'm not sure how to make the collector return what I'm looking for.</p>
  
  <pre><code>IntStream.range(0, days)
          .mapToObj(idx -&gt; new DateTime().withTimeAtStartOfDay().minusDays(idx).toDate())
          .map(date -&gt; {
              Tuple&lt;Date, Long&gt; dateLongTuple = data.stream()
                      .map(arr -&gt; new Tuple&lt;&gt;(DateTime.parse(arr[0].toString(), DATE_FORMATTER).toDate(), (Long) arr[1]))
                      .filter(tuple -&gt; date.equals(tuple.getX()))
                      .findFirst().orElse(new Tuple&lt;&gt;(date, 0L));
  
              return new DateCount(dateLongTuple.getX(), dateLongTuple.getY());
          })
  </code></pre>