edu.asu.diging.gilesecosystem.util.store.objectdb.PropertiesCopier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of giles-eco-util Show documentation
Show all versions of giles-eco-util Show documentation
Utility plugin for the Giles Ecoystem that for example provides utility classes
for properties or file management.
The newest version!
package edu.asu.diging.gilesecosystem.util.store.objectdb;
import java.lang.reflect.Field;
import org.springframework.stereotype.Service;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.ReflectionUtils.FieldCallback;
import edu.asu.diging.gilesecosystem.util.store.IPropertiesCopier;
@Service
public class PropertiesCopier implements IPropertiesCopier {
/* (non-Javadoc)
* @see edu.asu.diging.gilesecosystem.web.service.impl.IPropertiesCopier#copyObject(java.lang.Object, java.lang.Object)
*/
@Override
public void copyObject(Object objectToCopy, Object copyInto) {
ReflectionUtils.doWithFields(objectToCopy.getClass(), new FieldCallback() {
@Override
public void doWith(Field field) throws IllegalArgumentException,
IllegalAccessException {
field.setAccessible(true);
ReflectionUtils.setField(field, copyInto, ReflectionUtils.getField(field, objectToCopy));
}
});
}
}