gu.sql2java.json.FastjsonSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sql2java-base Show documentation
Show all versions of sql2java-base Show documentation
sql2java common class package
package gu.sql2java.json;
import static com.google.common.base.MoreObjects.firstNonNull;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.gitee.l0km.beanfilter.json.FastjsonFilterableSerializer;
import gu.sql2java.BaseBean;
import gu.sql2java.RowMetaData;
/**
* @author guyadong
* @since 3.32.0
*/
public class FastjsonSerializer extends FastjsonFilterableSerializer{
public FastjsonSerializer(Class extends BaseBean> beanType) {
super(beanType);
}
/**
* define FASTJSON serializer for all class derived from BaseBean using {@link SerializeConfig#getGlobalInstance()}
*/
public static void install() {
install(SerializeConfig.getGlobalInstance());
}
/**
* define FASTJSON serializer for all class derived from BaseBean
* @param config using {@link SerializeConfig#getGlobalInstance()} instead of {@code null}
*/
public static void install(SerializeConfig config) {
config = firstNonNull(config,SerializeConfig.getGlobalInstance());
for(RowMetaData metaData:RowMetaData.allMetaDataList()){
config.put(
metaData.beanType,
new FastjsonSerializer(metaData.beanType));
}
}
}