What i'm trying to accomplish is to run a method in my stream's map, based in that if the return is correct, to add it to the success list which would go in the collection's map key, if failure, it would be added to the failure list which would go in the collection's value:
List<String> success = new ArrayList<>();
List<String> failure = new ArrayList<>();
Map<List<String>,List<String>> masterLista = new HashMap<>();
masterLista.put(success, failure);
masterLista = list.stream().map(l -> {
String newS=serviceApi.getClearSongName(l);
if(newS!=null){
//Here the return should update the sucess list
return serviceApi.getClearSongName(l);
} else{
//Here the return should update the failure list
return l;
}
}).collect(Collectors.toList());
Actually the collection's map is not something necessary, the only thing i'd like to have is to inside the Stream's map already update two lists with successes and failures to avoid having to do a further processing inside a single list.
Edit: I'm using stream because actually the goal is to use parallelStream