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

gu.sql2java.json.FastjsonSerializer Maven / Gradle / Ivy

There is a newer version: 5.2.0
Show newest version
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 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));
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy