com.wujiuye.hotkit.json.jackson.ObjectMapperSub Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hotkit-json Show documentation
Show all versions of hotkit-json Show documentation
hotkits项目集合中的一员,JSON适配器组件,让切换JSON解析框架只需要切换依赖包即可。
The newest version!
package com.wujiuye.hotkit.json.jackson;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashSet;
import java.util.Set;
/**
* @author wujiuye 2020/09/09
*/
public class ObjectMapperSub extends ObjectMapper {
private Set> strategys = new HashSet<>();
public void putStrategy(final Class> cla, JacksonExclusionStrategy strategy) {
if (strategys.contains(cla)) {
return;
}
synchronized (this) {
if (strategys.contains(cla)) {
return;
}
Set> newSet = new HashSet<>();
newSet.add(cla);
strategys = newSet;
this.setFilterProvider(strategy);
// 将@JsonFilter 作用于 java 对象上
this.addMixIn(cla, JacksonExclusionStrategy.MyFilter.class);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy