50
50
import org .springframework .data .annotation .Reference ;
51
51
import org .springframework .data .convert .CustomConversions ;
52
52
import org .springframework .data .convert .TypeMapper ;
53
- import org .springframework .data .mapping .AccessOptions ;
54
- import org .springframework .data .mapping .Association ;
55
- import org .springframework .data .mapping .MappingException ;
56
- import org .springframework .data .mapping .Parameter ;
57
- import org .springframework .data .mapping .PersistentEntity ;
58
- import org .springframework .data .mapping .PersistentProperty ;
59
- import org .springframework .data .mapping .PersistentPropertyAccessor ;
60
- import org .springframework .data .mapping .PersistentPropertyPath ;
61
- import org .springframework .data .mapping .PersistentPropertyPathAccessor ;
62
- import org .springframework .data .mapping .PreferredConstructor ;
53
+ import org .springframework .data .mapping .*;
63
54
import org .springframework .data .mapping .callback .EntityCallbacks ;
64
55
import org .springframework .data .mapping .context .MappingContext ;
65
56
import org .springframework .data .mapping .model .ConvertingPropertyAccessor ;
@@ -123,7 +114,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
123
114
private static final String INCOMPATIBLE_TYPES = "Cannot convert %1$s of type %2$s into an instance of %3$s; Implement a custom Converter<%2$s, %3$s> and register it with the CustomConversions; Parent object was: %4$s" ;
124
115
private static final String INVALID_TYPE_TO_READ = "Expected to read Document %s into type %s but didn't find a PersistentEntity for the latter" ;
125
116
126
- public static final ClassTypeInformation <Bson > BSON = ClassTypeInformation . from (Bson .class );
117
+ public static final TypeInformation <Bson > BSON = TypeInformation . of (Bson .class );
127
118
128
119
protected static final Log LOGGER = LogFactory .getLog (MappingMongoConverter .class );
129
120
@@ -353,9 +344,9 @@ String getFieldName(MongoPersistentProperty prop) {
353
344
}
354
345
};
355
346
356
- PreferredConstructor <?, MongoPersistentProperty > persistenceConstructor = mappedEntity .getPersistenceConstructor ();
357
- ParameterValueProvider <MongoPersistentProperty > provider = persistenceConstructor != null
358
- && persistenceConstructor .hasParameters ()
347
+ InstanceCreatorMetadata < MongoPersistentProperty > instanceCreatorMetadata = mappedEntity .getInstanceCreatorMetadata ();
348
+ ParameterValueProvider <MongoPersistentProperty > provider = instanceCreatorMetadata != null
349
+ && instanceCreatorMetadata .hasParameters ()
359
350
? getParameterProvider (context , mappedEntity , documentAccessor , evaluator )
360
351
: NoOpParameterValueProvider .INSTANCE ;
361
352
@@ -405,7 +396,7 @@ public Map<String, Object> getBean() {
405
396
}
406
397
407
398
public <S extends Object > S read (Class <S > clazz , Bson bson ) {
408
- return read (ClassTypeInformation . from (clazz ), bson );
399
+ return read (TypeInformation . of (clazz ), bson );
409
400
}
410
401
411
402
protected <S extends Object > S read (TypeInformation <S > type , Bson bson ) {
@@ -498,10 +489,10 @@ private <S> S read(ConversionContext context, MongoPersistentEntity<S> entity, D
498
489
SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator (bson , spELContext );
499
490
DocumentAccessor documentAccessor = new DocumentAccessor (bson );
500
491
501
- PreferredConstructor < S , MongoPersistentProperty > persistenceConstructor = entity .getPersistenceConstructor ();
492
+ InstanceCreatorMetadata < MongoPersistentProperty > instanceCreatorMetadata = entity .getInstanceCreatorMetadata ();
502
493
503
- ParameterValueProvider <MongoPersistentProperty > provider = persistenceConstructor != null
504
- && persistenceConstructor .hasParameters () ? getParameterProvider (context , entity , documentAccessor , evaluator )
494
+ ParameterValueProvider <MongoPersistentProperty > provider = instanceCreatorMetadata != null
495
+ && instanceCreatorMetadata .hasParameters () ? getParameterProvider (context , entity , documentAccessor , evaluator )
505
496
: NoOpParameterValueProvider .INSTANCE ;
506
497
507
498
EntityInstantiator instantiator = instantiators .getInstantiatorFor (entity );
@@ -552,7 +543,7 @@ private Object readAndPopulateIdentifier(ConversionContext context, PersistentPr
552
543
553
544
MongoPersistentProperty idProperty = entity .getRequiredIdProperty ();
554
545
555
- if (idProperty .isImmutable () && entity .isConstructorArgument (idProperty )) {
546
+ if (idProperty .isImmutable () && entity .isCreatorArgument (idProperty )) {
556
547
return rawId ;
557
548
}
558
549
@@ -587,7 +578,7 @@ private void readProperties(ConversionContext context, MongoPersistentEntity<?>
587
578
ConversionContext propertyContext = context .forProperty (prop );
588
579
MongoDbPropertyValueProvider valueProviderToUse = valueProvider .withContext (propertyContext );
589
580
590
- if (prop .isAssociation () && !entity .isConstructorArgument (prop )) {
581
+ if (prop .isAssociation () && !entity .isCreatorArgument (prop )) {
591
582
592
583
if (callback == null ) {
593
584
callback = getDbRefResolverCallback (propertyContext , documentAccessor , evaluator );
@@ -761,7 +752,7 @@ public void write(Object obj, Bson bson) {
761
752
}
762
753
763
754
Class <?> entityType = ClassUtils .getUserClass (obj .getClass ());
764
- TypeInformation <? extends Object > type = ClassTypeInformation . from (entityType );
755
+ TypeInformation <? extends Object > type = TypeInformation . of (entityType );
765
756
766
757
Object target = obj instanceof LazyLoadingProxy ? ((LazyLoadingProxy ) obj ).getTarget () : obj ;
767
758
@@ -805,12 +796,12 @@ protected void writeInternal(@Nullable Object obj, Bson bson, @Nullable TypeInfo
805
796
}
806
797
807
798
if (Map .class .isAssignableFrom (entityType )) {
808
- writeMapInternal ((Map <Object , Object >) obj , bson , ClassTypeInformation .MAP );
799
+ writeMapInternal ((Map <Object , Object >) obj , bson , TypeInformation .MAP );
809
800
return ;
810
801
}
811
802
812
803
if (Collection .class .isAssignableFrom (entityType )) {
813
- writeCollectionInternal ((Collection <?>) obj , ClassTypeInformation .LIST , (Collection <?>) bson );
804
+ writeCollectionInternal ((Collection <?>) obj , TypeInformation .LIST , (Collection <?>) bson );
814
805
return ;
815
806
}
816
807
@@ -896,7 +887,7 @@ protected void writePropertyInternal(@Nullable Object obj, DocumentAccessor acce
896
887
return ;
897
888
}
898
889
899
- TypeInformation <?> valueType = ClassTypeInformation . from (obj .getClass ());
890
+ TypeInformation <?> valueType = TypeInformation . of (obj .getClass ());
900
891
TypeInformation <?> type = prop .getTypeInformation ();
901
892
902
893
if (conversions .hasValueConverter (prop )) {
@@ -977,7 +968,7 @@ protected void writePropertyInternal(@Nullable Object obj, DocumentAccessor acce
977
968
Document document = existingValue instanceof Document ? (Document ) existingValue : new Document ();
978
969
979
970
writeInternal (obj , document , entity );
980
- addCustomTypeKeyIfNecessary (ClassTypeInformation . from (prop .getRawType ()), obj , document );
971
+ addCustomTypeKeyIfNecessary (TypeInformation . of (prop .getRawType ()), obj , document );
981
972
accessor .put (prop , document );
982
973
}
983
974
@@ -998,7 +989,7 @@ protected List<Object> createCollection(Collection<?> collection, MongoPersisten
998
989
.getPointer ();
999
990
}).collect (Collectors .toList ());
1000
991
1001
- return writeCollectionInternal (targetCollection , ClassTypeInformation . from (DocumentPointer .class ),
992
+ return writeCollectionInternal (targetCollection , TypeInformation . of (DocumentPointer .class ),
1002
993
new ArrayList <>());
1003
994
}
1004
995
@@ -1127,7 +1118,7 @@ protected Bson writeMapInternal(Map<Object, Object> obj, Bson bson, TypeInformat
1127
1118
} else {
1128
1119
Document document = new Document ();
1129
1120
TypeInformation <?> valueTypeInfo = propertyType .isMap () ? propertyType .getMapValueType ()
1130
- : ClassTypeInformation .OBJECT ;
1121
+ : TypeInformation .OBJECT ;
1131
1122
writeInternal (val , document , valueTypeInfo );
1132
1123
BsonUtils .addToMap (bson , simpleKey , document );
1133
1124
}
@@ -1379,7 +1370,7 @@ protected Object readCollectionOrArray(ConversionContext context, Collection<?>
1379
1370
1380
1371
TypeInformation <?> componentType = targetType .getComponentType () != null //
1381
1372
? targetType .getComponentType () //
1382
- : ClassTypeInformation .OBJECT ;
1373
+ : TypeInformation .OBJECT ;
1383
1374
Class <?> rawComponentType = componentType .getType ();
1384
1375
1385
1376
Collection <Object > items = targetType .getType ().isArray () //
@@ -1421,7 +1412,7 @@ protected Map<Object, Object> readMap(ConversionContext context, Bson bson, Type
1421
1412
Class <?> mapType = getTypeMapper ().readType (bson , targetType ).getType ();
1422
1413
1423
1414
TypeInformation <?> keyType = targetType .getComponentType ();
1424
- TypeInformation <?> valueType = targetType .getMapValueType () == null ? ClassTypeInformation .OBJECT
1415
+ TypeInformation <?> valueType = targetType .getMapValueType () == null ? TypeInformation .OBJECT
1425
1416
: targetType .getRequiredMapValueType ();
1426
1417
1427
1418
Class <?> rawKeyType = keyType != null ? keyType .getType () : Object .class ;
@@ -1827,7 +1818,7 @@ static Predicate<MongoPersistentProperty> isIdentifier(PersistentEntity<?, ?> en
1827
1818
}
1828
1819
1829
1820
static Predicate <MongoPersistentProperty > isConstructorArgument (PersistentEntity <?, ?> entity ) {
1830
- return entity ::isConstructorArgument ;
1821
+ return entity ::isCreatorArgument ;
1831
1822
}
1832
1823
1833
1824
/**
@@ -2046,7 +2037,7 @@ public boolean isCollectionLike() {
2046
2037
2047
2038
@ Override
2048
2039
public org .springframework .data .util .TypeInformation <?> getComponentType () {
2049
- return ClassTypeInformation . from (persistentProperty .getFieldType ());
2040
+ return TypeInformation . of (persistentProperty .getFieldType ());
2050
2041
}
2051
2042
2052
2043
@ Override
@@ -2056,7 +2047,7 @@ public boolean isMap() {
2056
2047
2057
2048
@ Override
2058
2049
public org .springframework .data .util .TypeInformation <?> getMapValueType () {
2059
- return ClassTypeInformation . from (persistentProperty .getFieldType ());
2050
+ return TypeInformation . of (persistentProperty .getFieldType ());
2060
2051
}
2061
2052
2062
2053
@ Override
0 commit comments