ru.greatbit.utils.beans.CopyBeanUtils Maven / Gradle / Ivy
package ru.greatbit.utils.beans;
import ru.greatbit.utils.serialize.JsonSerializer;
/**
* Created by azee on 4/11/14.
*/
public class CopyBeanUtils {
/**
* Get a copy of an object
* @param source - a source object
* @param - class of the object
* @return - a copy of the object
* @throws Exception - Serialization Exceptions
*/
public static T getCopy(Object source) throws Exception {
String sourceString = JsonSerializer.marshal(source);
Class clazz = source.getClass();
return (T) JsonSerializer.unmarshal(sourceString, clazz);
}
}