001package org.jadira.scanner.core.concurrent; 002 003import java.util.List; 004import java.util.stream.Collectors; 005 006import org.jadira.scanner.core.api.Allocator; 007 008import jsr166y.RecursiveTask; 009 010public class AllocatorTask<T,A> extends RecursiveTask<List<T>> { 011 012 private static final long serialVersionUID = -5338937563634945167L; 013 014 private final Allocator<T,A> allocator; 015 private final List<A> inputs; 016 017 public AllocatorTask(final Allocator<T,A> allocator, final List<A> inputs) { 018 019 this.allocator = allocator; 020 this.inputs = inputs; 021 } 022 023 @Override 024 public List<T> compute() { 025 026 List<T> result = inputs.stream() 027 .map( a -> allocator.allocate(a) ) 028 .collect( Collectors.toList() ); 029 030 return result; 031 } 032}