支付跑通

This commit is contained in:
maxf 2019-01-07 17:18:52 +08:00
parent 6c186e39cd
commit c9863373fe

View File

@ -2,6 +2,7 @@ package com.yexuejc.base.util;
import java.io.*; import java.io.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.sql.Timestamp;
import java.util.*; import java.util.*;
/** /**
@ -116,7 +117,7 @@ public class ObjUtil {
} }
} }
Object o = f.get(obj); Object o = f.get(obj);
if (null == o || o.getClass().isPrimitive() || o instanceof String || o instanceof Enum) { if (null == o || isPrimitive(o) || o instanceof String || o instanceof Enum) {
if (null == o && !putNull) { if (null == o && !putNull) {
continue; continue;
} }
@ -133,6 +134,23 @@ public class ObjUtil {
if (bodyList.size() > 0) { if (bodyList.size() > 0) {
objMap.put(fName, bodyList); objMap.put(fName, bodyList);
} }
} else if (o instanceof Map) {
Map map = (Map) o;
if (map.size() > 0) {
objMap.put(fName, map);
}
} else if (o instanceof Set) {
Set list = (Set) o;
Set bodyList = new HashSet();
list.forEach(it -> {
if (null != it) {
Map<String, Object> underlineMap = getUnderlineMap(it, isAnnotationAll, putNull);
bodyList.add(underlineMap);
}
});
if (bodyList.size() > 0) {
objMap.put(fName, bodyList);
}
} else { } else {
Map<String, Object> underlineMap = getUnderlineMap(o, isAnnotationAll, putNull); Map<String, Object> underlineMap = getUnderlineMap(o, isAnnotationAll, putNull);
objMap.put(fName, underlineMap); objMap.put(fName, underlineMap);
@ -144,6 +162,27 @@ public class ObjUtil {
return objMap; return objMap;
} }
/**
* 判断是否基本类型包括String,BigDecimal,Number
*
* @param obj
* @return
*/
public static boolean isPrimitive(Object obj) {
if (null == obj) {
return false;
}
boolean b = obj.getClass().isPrimitive()
|| obj instanceof Integer || obj instanceof Character || obj instanceof Boolean
|| obj instanceof Number || obj instanceof String || obj instanceof Double || obj instanceof Float
|| obj instanceof Short || obj instanceof Long || obj instanceof Byte || obj instanceof Date
;
if (b) {
return true;
}
return false;
}
public static void main(String[] args) { public static void main(String[] args) {
B a = new B(); B a = new B();