Skip to content

Commit

Permalink
[#1878] Avoid overriding a user provided deserializer
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Jul 20, 2024
1 parent 510724e commit 2865898
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.deser.AbstractDeserializer;
import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;
import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
import com.fasterxml.jackson.databind.module.SimpleModule;
Expand All @@ -51,14 +52,22 @@ public EntityViewAwareObjectMapper(final EntityViewManager entityViewManager, fi

public EntityViewAwareObjectMapper(final EntityViewManager entityViewManager, final ObjectMapper objectMapper, final EntityViewIdValueAccessor entityViewIdValueAccessor) {
this.entityViewManager = entityViewManager;
SimpleModule module = new SimpleModule();
SimpleModule module = new SimpleModule("Blaze-Persistence" );

module.setDeserializerModifier(new BeanDeserializerModifier() {
@Override
public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
ManagedViewType<?> view = entityViewManager.getMetamodel().managedView(beanDesc.getBeanClass());
if (view != null) {
return new EntityViewReferenceDeserializer(entityViewManager, view, objectMapper, beanDesc.getIgnoredPropertyNames(), entityViewIdValueAccessor);
if ( deserializer instanceof AbstractDeserializer ) {
ManagedViewType<?> view = entityViewManager.getMetamodel().managedView( beanDesc.getBeanClass() );
if ( view != null ) {
return new EntityViewReferenceDeserializer(
entityViewManager,
view,
objectMapper,
beanDesc.getIgnoredPropertyNames(),
entityViewIdValueAccessor
);
}
}
return deserializer;
}
Expand Down

0 comments on commit 2865898

Please sign in to comment.