package com.test.demo.utils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class CompareUtil {
/* private List> list=new ArrayList<>();
private List> list2=new ArrayList<>();*/
public static boolean compareMap(List> list,List> list2) {
Boolean isSucess=false;
long st = System.nanoTime();
if (list.size() != list2.size()) {
System.out.println("getDiffrent total times " + (System.nanoTime() - st));
return isSucess;
}
int i=0;
for (Map map : list) {
for (Map.Entry entry1 : map.entrySet()) {
String m1key = entry1.getKey();
Object m1value = entry1.getValue();
Map map2 = list2.get(i);
if (!map2.containsKey(m1key)){
System.out.println("lise2表不存在这样的列字段+"+m1key);
}else {
Object value2 = map2.get(m1key);
if (value2==null){
System.out.println("lise2表的这个列值为null"+m1key);
}else {
if (m1value.equals(value2)){
}else {
System.out.println("m1key:"+m1key+",value1="+m1value.toString()+",value2="+value2.toString());
System.out.println("lise2里面存在m1key对应的列,但是列对应的值不相等");
}
}
}
}
i++;
}
System.out.println("-------------------");
isSucess=true;
return isSucess;
}
}
网友评论