use of com.hubspot.rosetta.annotations.StoredAsJson in project Rosetta by HubSpot.
the class StoredAsJsonBeanSerializerModifier method changeProperties.
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
for (BeanPropertyWriter beanProperty : beanProperties) {
StoredAsJson storedAsJson = beanProperty.getAnnotation(StoredAsJson.class);
if (storedAsJson != null && !StoredAsJson.NULL.equals(storedAsJson.empty())) {
final JsonSerializer<Object> nullSerializer;
if (storedAsJson.binary()) {
nullSerializer = new ConstantBinarySerializer(storedAsJson.empty());
} else {
nullSerializer = new ConstantSerializer(storedAsJson.empty());
}
beanProperty.assignNullSerializer(nullSerializer);
}
}
return super.changeProperties(config, beanDesc, beanProperties);
}
Aggregations