use of com.baeldung.jackson.dynamicIgnore.HidableSerializer in project tutorials by eugenp.
the class JacksonDynamicIgnoreUnitTest method setUp.
@Before
public void setUp() {
mapper.setSerializationInclusion(Include.NON_EMPTY);
mapper.registerModule(new SimpleModule() {
@Override
public void setupModule(final SetupContext context) {
super.setupModule(context);
context.addBeanSerializerModifier(new BeanSerializerModifier() {
@Override
public JsonSerializer<?> modifySerializer(final SerializationConfig config, final BeanDescription beanDesc, final JsonSerializer<?> serializer) {
if (Hidable.class.isAssignableFrom(beanDesc.getBeanClass())) {
return new HidableSerializer((JsonSerializer<Object>) serializer);
}
return serializer;
}
});
}
});
}
Aggregations