Update SerializationUtils.java

Updating serialization Utils
This commit is contained in:
Amitabh Tiwari 2021-10-15 19:25:52 +05:30
parent 98528e849e
commit 008e340482
1 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
public class SerializationUtils {
@ -26,6 +27,15 @@ public class SerializationUtils {
}
public static boolean isSerializable(Class<?> it) {
return it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it);
boolean serializable = it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it);
if(!serializable) {
return serializable;
}
Field[] declaredFields = it.getDeclaredFields();
for(Field field: declaredFields) {
Class<?> fieldType = field.getType();
return isSerializable(fieldType);
}
return serializable;
}
}