4848import org .springframework .data .rest .webmvc .mapping .Associations ;
4949import org .springframework .data .rest .webmvc .mapping .LinkCollector ;
5050import org .springframework .data .util .CastUtils ;
51+ import org .springframework .data .util .TypeInformation ;
5152import org .springframework .hateoas .EntityModel ;
5253import org .springframework .hateoas .Link ;
5354import org .springframework .hateoas .Links ;
@@ -427,7 +428,6 @@ public static class AssociationUriResolvingDeserializerModifier extends BeanDese
427428 private final UriToEntityConverter converter ;
428429 private final RepositoryInvokerFactory factory ;
429430
430- @ java .lang .SuppressWarnings ("all" )
431431 public AssociationUriResolvingDeserializerModifier (PersistentEntities entities , Associations associations ,
432432 UriToEntityConverter converter , RepositoryInvokerFactory factory ) {
433433
@@ -451,27 +451,26 @@ public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanD
451451 BeanDeserializerBuilder builder ) {
452452
453453 ValueInstantiatorCustomizer customizer = new ValueInstantiatorCustomizer (builder .getValueInstantiator (), config );
454-
455454 Iterator <SettableBeanProperty > properties = builder .getProperties ();
456455
457456 entities .getPersistentEntity (beanDesc .getBeanClass ()).ifPresent (entity -> {
458457
459458 while (properties .hasNext ()) {
460459
461460 SettableBeanProperty property = properties .next ();
462-
463461 PersistentProperty <?> persistentProperty = entity .getPersistentProperty (property .getName ());
464462
465463 if (persistentProperty == null ) {
466464 continue ;
467465 }
468466
467+ TypeInformation <?> propertyType = persistentProperty .getTypeInformation ();
468+
469469 if (associationLinks .isLookupType (persistentProperty )) {
470470
471471 RepositoryInvokingDeserializer repositoryInvokingDeserializer = new RepositoryInvokingDeserializer (factory ,
472472 persistentProperty );
473- JsonDeserializer <?> deserializer = wrapIfCollection (persistentProperty , repositoryInvokingDeserializer ,
474- config );
473+ JsonDeserializer <?> deserializer = wrapIfCollection (propertyType , repositoryInvokingDeserializer , config );
475474
476475 builder .addOrReplaceProperty (property .withValueDeserializer (deserializer ), false );
477476 continue ;
@@ -481,8 +480,9 @@ public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanD
481480 continue ;
482481 }
483482
484- UriStringDeserializer uriStringDeserializer = new UriStringDeserializer (persistentProperty , converter );
485- JsonDeserializer <?> deserializer = wrapIfCollection (persistentProperty , uriStringDeserializer , config );
483+ Class <?> actualPropertyType = persistentProperty .getActualType ();
484+ UriStringDeserializer uriStringDeserializer = new UriStringDeserializer (actualPropertyType , converter );
485+ JsonDeserializer <?> deserializer = wrapIfCollection (propertyType , uriStringDeserializer , config );
486486
487487 customizer .replacePropertyIfNeeded (builder , property .withValueDeserializer (deserializer ));
488488 }
@@ -519,7 +519,7 @@ static class ValueInstantiatorCustomizer {
519519
520520 /**
521521 * Replaces the logically same property with the given {@link SettableBeanProperty} on the given
522- * {@link BeanDeserializerBuilder}. In case we get a {@link CreatorProperty} we als register that one to be later
522+ * {@link BeanDeserializerBuilder}. In case we get a {@link CreatorProperty} we also register that one to be later
523523 * exposed via the {@link ValueInstantiator} backing the {@link BeanDeserializerBuilder}.
524524 *
525525 * @param builder must not be {@literal null}.
@@ -559,15 +559,15 @@ BeanDeserializerBuilder conclude(BeanDeserializerBuilder builder) {
559559 }
560560 }
561561
562- private static JsonDeserializer <?> wrapIfCollection (PersistentProperty <?> property ,
562+ private static JsonDeserializer <?> wrapIfCollection (TypeInformation <?> property ,
563563 JsonDeserializer <Object > elementDeserializer , DeserializationConfig config ) {
564564
565565 if (!property .isCollectionLike ()) {
566566 return elementDeserializer ;
567567 }
568568
569569 CollectionLikeType collectionType = config .getTypeFactory ().constructCollectionLikeType (property .getType (),
570- property .getActualType ());
570+ property .getActualType (). getType () );
571571 CollectionValueInstantiator instantiator = new CollectionValueInstantiator (property );
572572 return new CollectionDeserializer (collectionType , elementDeserializer , null , instantiator );
573573 }
@@ -580,26 +580,26 @@ private static JsonDeserializer<?> wrapIfCollection(PersistentProperty<?> proper
580580 * @author Oliver Gierke
581581 * @author Valentin Rentschler
582582 */
583- static class UriStringDeserializer extends StdDeserializer <Object > {
583+ public static class UriStringDeserializer extends StdDeserializer <Object > {
584584
585585 private static final long serialVersionUID = -2175900204153350125L ;
586586 private static final String UNEXPECTED_VALUE = "Expected URI cause property %s points to the managed domain type!" ;
587587
588- private final PersistentProperty <?> property ;
588+ private final Class <?> type ;
589589 private final UriToEntityConverter converter ;
590590
591591 /**
592592 * Creates a new {@link UriStringDeserializer} for the given {@link PersistentProperty} using the given
593593 * {@link UriToEntityConverter}.
594594 *
595- * @param property must not be {@literal null}.
595+ * @param type must not be {@literal null}.
596596 * @param converter must not be {@literal null}.
597597 */
598- public UriStringDeserializer (PersistentProperty <?> property , UriToEntityConverter converter ) {
598+ public UriStringDeserializer (Class <?> type , UriToEntityConverter converter ) {
599599
600- super (property . getActualType () );
600+ super (type );
601601
602- this .property = property ;
602+ this .type = type ;
603603 this .converter = converter ;
604604 }
605605
@@ -618,11 +618,11 @@ public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOE
618618
619619 try {
620620 URI uri = UriTemplate .of (source ).expand ();
621- TypeDescriptor typeDescriptor = TypeDescriptor .valueOf (property . getActualType () );
621+ TypeDescriptor typeDescriptor = TypeDescriptor .valueOf (type );
622622
623623 return converter .convert (uri , URI_DESCRIPTOR , typeDescriptor );
624624 } catch (IllegalArgumentException o_O ) {
625- throw ctxt .weirdStringException (source , URI .class , String .format (UNEXPECTED_VALUE , property ));
625+ throw ctxt .weirdStringException (source , URI .class , String .format (UNEXPECTED_VALUE , type ));
626626 }
627627 }
628628
@@ -813,16 +813,16 @@ public JsonSerializer<ProjectionResourceContent> unwrappingSerializer(NameTransf
813813 *
814814 * @author Oliver Gierke
815815 */
816- private static class CollectionValueInstantiator extends ValueInstantiator {
816+ static class CollectionValueInstantiator extends ValueInstantiator {
817817
818- private final PersistentProperty <?> property ;
818+ private final TypeInformation <?> property ;
819819
820820 /**
821821 * Creates a new {@link CollectionValueInstantiator} for the given {@link PersistentProperty}.
822822 *
823823 * @param property must not be {@literal null} and must be a collection.
824824 */
825- public CollectionValueInstantiator (PersistentProperty <?> property ) {
825+ public CollectionValueInstantiator (TypeInformation <?> property ) {
826826
827827 Assert .notNull (property , "Property must not be null!" );
828828 Assert .isTrue (property .isCollectionLike () || property .isMap (), "Property must be a collection or map property!" );
0 commit comments