package com.lizi.admin.utils.contrast;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class EntityUtil {
private static String GET_METHOD_PREFIX = "get";
public static <T> Object getFieldValue(T t, String fieldName) throws IllegalArgumentException, NoSuchMethodException, SecurityException, IllegalAccessException, InvocationTargetException{
String methodName = getGetMethodRealName(fieldName);
if(methodName == null){
throw new IllegalArgumentException("外部订单号不能为空");
}
Class<?> clazz = t.getClass();
Method getMethod = clazz.getMethod(methodName);
return getMethod.invoke(t);
}
private static String getGetMethodRealName(String fieldName){
if(fieldName == null || fieldName.length() ==0){
return null;
}
String getMethodRealName = GET_METHOD_PREFIX + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
return getMethodRealName;
}
}
package com.lizi.admin.utils.contrast;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ListUtils {
private static <T> boolean isBaseEqual(List<T> first, List<T> second){
if(first == null || second == null || first.size() == 0 || second.size() == 0){
return false;
}
return true;
}
/**
* 获取在第一个集合中但是不在第二个集合中的数据
* @param first 第一个集合
* @param second 第二个集合
* @param compareFieldName 需要比较的属性名称
* @return
* @throws IllegalArgumentException
* @throws NoSuchMethodException
* @throws SecurityException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
public static <T> List<T> getInFirstNotInSecondList(List<
T> first, List<T> second, String compareFieldName) throws IllegalArgumentException, NoSuchMethodException, SecurityException, IllegalAccessException, InvocationTargetException{
List<T> result = new ArrayList<>();
if(isBaseEqual(first, second)){
Map<String, String> listMap = new HashMap<>();
String temp;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class EntityUtil {
private static String GET_METHOD_PREFIX = "get";
public static <T> Object getFieldValue(T t, String fieldName) throws IllegalArgumentException, NoSuchMethodException, SecurityException, IllegalAccessException, InvocationTargetException{
String methodName = getGetMethodRealName(fieldName);
if(methodName == null){
throw new IllegalArgumentException("外部订单号不能为空");
}
Class<?> clazz = t.getClass();
Method getMethod = clazz.getMethod(methodName);
return getMethod.invoke(t);
}
private static String getGetMethodRealName(String fieldName){
if(fieldName == null || fieldName.length() ==0){
return null;
}
String getMethodRealName = GET_METHOD_PREFIX + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
return getMethodRealName;
}
}
package com.lizi.admin.utils.contrast;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ListUtils {
private static <T> boolean isBaseEqual(List<T> first, List<T> second){
if(first == null || second == null || first.size() == 0 || second.size() == 0){
return false;
}
return true;
}
/**
* 获取在第一个集合中但是不在第二个集合中的数据
* @param first 第一个集合
* @param second 第二个集合
* @param compareFieldName 需要比较的属性名称
* @return
* @throws IllegalArgumentException
* @throws NoSuchMethodException
* @throws SecurityException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
public static <T> List<T> getInFirstNotInSecondList(List<
T> first, List<T> second, String compareFieldName) throws IllegalArgumentException, NoSuchMethodException, SecurityException, IllegalAccessException, InvocationTargetException{
List<T> result = new ArrayList<>();
if(isBaseEqual(first, second)){
Map<String, String> listMap = new HashMap<>();
String temp;