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

com.iqiny.silly.spring.spel.field.SillyPrintValuesField Maven / Gradle / Ivy

/*
 *  Copyright  iqiny.com
 *
 *  https://gitee.com/iqiny/silly
 *
 *  project name:silly-spring
 *  project description:top silly project pom.xml file
 */
package com.iqiny.silly.spring.spel.field;

import com.iqiny.silly.common.util.SillyObjectUtil;
import com.iqiny.silly.core.config.property.valuesfield.BaseSillyMethodPropertyValuesField;
import com.iqiny.silly.core.savehandle.SillyOnceSourceData;
import org.springframework.stereotype.Component;

/**
 * 打印数据到控制台,用于测试
 */
@Component
public class SillyPrintValuesField extends BaseSillyMethodPropertyValuesField {

    public static final String NAME = "print" ;

    @Override
    public String fieldName() {
        return NAME;
    }

    @Override
    protected Class[] getParameterTypes(SillyOnceSourceData data) {
        return new Class[]{Object.class};
    }

    public static Object print(Object obj) {
        StringBuilder sb = new StringBuilder();
        sb.append("======>> Silly数据打印  \r\nJSON值为:");
        if (obj == null) {
            sb.append("null");
        } else {
            sb.append(SillyObjectUtil.objectToJsonString(obj));
            sb.append("\r\n对象值为:");
            sb.append(obj.toString());
        }
        sb.append("\r\n<<======");
        System.out.println(sb);
        return obj;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy