All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy