this simple
can parallel stream+map+collector is very convenient
code, I am not convenient to tap the code now, have time to make up for you, but need your project support jdk8
update (sorry, I just went to work, wrote it for you, see if it matches your business, try efficiency, and, of course, there is room for improvement.)
Note: business methods are decorated with private
to avoid exposure
public class Test {
public static void main(String[] args) {
//
List<Map<String, Object>> input = new ArrayList<Map<String, Object>>() {{
add(Collections.singletonMap("one", 1));
add(Collections.singletonMap("two", 2));
add(Collections.singletonMap("three", 3));
trimToSize();
}};
//
List<Map<String,String>> output = input.parallelStream().map(Test::convert).collect(toList());
//
output.forEach(m->{
m.forEach((k, v)-> System.out.println(k + "\t" + v));
});
}
/**
*
* */
private static Map<String, String> convert(Map<String, Object> map) {
Objects.requireNonNull(map);
Map<String, String> result = new ConcurrentHashMap<>(map.size());
// compute
map.forEach((key, value) -> result.put(key, value.toString()));
return result;
}
}