cn.schoolwow.util.module.beanCopy.flow.CopyPropertiesFlow Maven / Gradle / Ivy
package cn.schoolwow.util.module.beanCopy.flow;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.domain.query.instance.QueryInstance;
import cn.schoolwow.util.domain.query.reflection.QueryReflection;
import java.lang.reflect.Field;
import java.util.List;
public class CopyPropertiesFlow implements BusinessFlow {
@Override
public void executeBusinessFlow(FlowContext flowContext) throws Exception {
Object cloneObject = flowContext.checkData("cloneObject");
Object target = flowContext.checkData("target");
List fieldList = QueryReflection.newQuery(cloneObject.getClass())
.execute()
.getFieldList();
QueryInstance queryInstance = QueryInstance.newQuery(target);
for(Field field:fieldList){
Object fieldValue = field.get(cloneObject);
queryInstance.setFieldValue(field.getName(), fieldValue);
}
}
@Override
public String name() {
return "复制实例成员变量";
}
}