import cn.hutool.core.util.StrUtil;
import com.fjhx.sale.entity.statement.vo.ProfitSettlementVo;

import java.lang.reflect.Field;
import java.util.StringJoiner;

public class MyTest {

    public static void main(String[] args) {
        getSet("item", ProfitSettlementVo.class, "profitSettlementVo");
    }

    private static void getSet(String getName, Class<?> setClass, String setName) {

        StringJoiner joiner = new StringJoiner("\r\n");

        Field[] declaredFields = setClass.getDeclaredFields();
        for (Field field : declaredFields) {
            String name = field.getName();
            joiner.add(setName + "." + StrUtil.genSetter(name) + "(" + getName + "." + StrUtil.genGetter(name) + "());");
        }

        Class<?> superclass = setClass.getSuperclass();
        while (superclass != null) {
            Field[] declaredFields1 = superclass.getDeclaredFields();
            for (Field field : declaredFields1) {
                String name = field.getName();
                joiner.add(setName + "." + StrUtil.genSetter(name) + "(" + getName + "." + StrUtil.genGetter(name) + "());");
            }
            superclass = superclass.getSuperclass();
        }

        System.out.println(joiner);
    }

}
