title: Typesafe map-reduce in Java
body: <p>How to write a type-safe mapper/transformer of collections?</p>
  
  <pre><code>class Bean {
   public int value;
  }
  
  List&lt;Bean&gt; beans = ..
  
  List&lt;Integer&gt; ints = Lib.map(beans, b =&gt; b.value);
  </code></pre>
  
  <p>Using Apache Commons-Collections it looks like this:</p>
  
  <pre><code>    Collection&lt;Integer&gt; ints = CollectionUtils.collect(beans, new Transformer() {
          @Override
          public Object transform(Object input) {
              return null; //cast here, dereference etc.
          }
      });
  </code></pre>
  
  <p>But this isn't type safe</p>