1 package org.jadira.scanner.core.concurrent; 2 3 import java.util.List; 4 import java.util.stream.Collectors; 5 6 import org.jadira.scanner.core.api.Projector; 7 8 import jsr166y.RecursiveTask; 9 10 public class ProjectorTask<T> extends RecursiveTask<List<T>> { 11 12 private static final long serialVersionUID = -5338937563634945167L; 13 14 private final Projector<T> projector; 15 private final List<T> inputs; 16 17 public ProjectorTask(final Projector<T> projector, final List<T> inputs) { 18 19 this.projector = projector; 20 this.inputs = inputs; 21 } 22 23 @Override 24 public List<T> compute() { 25 26 List<T> result = inputs.stream() 27 .flatMap( t -> projector.project(t).stream() ) 28 .collect( Collectors.toList() ); 29 30 return result; 31 } 32 }