Generic type conversion in java

because the data obtained in the business file is all
List < Map < String,Object > >
, because the final data to be returned is all
List < Map < String,String > >
using foreach and map.entrySet () is a bit inefficient, is there a better solution

?
Apr.03,2021

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;
  }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ae5e-2c27b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ae5e-2c27b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?