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

cn.schoolwow.util.module.beanCopy.flow.CopyPropertiesFlow Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
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 "复制实例成员变量";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy