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.Allocator; 7 8 import jsr166y.RecursiveTask; 9 10 public class AllocatorTask<T,A> extends RecursiveTask<List<T>> { 11 12 private static final long serialVersionUID = -5338937563634945167L; 13 14 private final Allocator<T,A> allocator; 15 private final List<A> inputs; 16 17 public AllocatorTask(final Allocator<T,A> allocator, final List<A> inputs) { 18 19 this.allocator = allocator; 20 this.inputs = inputs; 21 } 22 23 @Override 24 public List<T> compute() { 25 26 List<T> result = inputs.stream() 27 .map( a -> allocator.allocate(a) ) 28 .collect( Collectors.toList() ); 29 30 return result; 31 } 32 }