|
|
@@ -7,6 +7,7 @@ import java.io.NotSerializableException;
|
|
|
import java.io.ObjectInputStream;
|
|
|
import java.io.ObjectOutputStream;
|
|
|
import java.io.Serializable;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
@@ -32,6 +33,42 @@ public class ObjectUtils {
|
|
|
|| (obj instanceof Map && CollectionUtils.isEmpty((Map<?, ?>) obj));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 将对象转为 String
|
|
|
+ *
|
|
|
+ * @param obj
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String toString(Object obj) {
|
|
|
+ if (obj == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ if (obj instanceof String) {
|
|
|
+ return (String) obj;
|
|
|
+ }
|
|
|
+ if (obj.getClass().isArray()) {
|
|
|
+ if (obj instanceof long[]) {
|
|
|
+ return Arrays.toString((long[]) obj);
|
|
|
+ } else if (obj instanceof int[]) {
|
|
|
+ return Arrays.toString((int[]) obj);
|
|
|
+ } else if (obj instanceof short[]) {
|
|
|
+ return Arrays.toString((short[]) obj);
|
|
|
+ } else if (obj instanceof byte[]) {
|
|
|
+ return Arrays.toString((byte[]) obj);
|
|
|
+ } else if (obj instanceof char[]) {
|
|
|
+ return Arrays.toString((char[]) obj);
|
|
|
+ } else if (obj instanceof boolean[]) {
|
|
|
+ return Arrays.toString((boolean[]) obj);
|
|
|
+ } else if (obj instanceof float[]) {
|
|
|
+ return Arrays.toString((float[]) obj);
|
|
|
+ } else if (obj instanceof double[]) {
|
|
|
+ return Arrays.toString((double[]) obj);
|
|
|
+ }
|
|
|
+ return Arrays.toString((Object[]) obj);
|
|
|
+ }
|
|
|
+ return obj.toString();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 深克隆对象
|
|
|
*
|